error trying to run a SSIS script using DotnetZip - sql-server

I've started using the dotnetzip from codeplex ...
I Downloaded it and referencing Ionic.ZIP.dll in my .net 4.5 application,
This is my main code...
using (ZipFile archive = new ZipFile(#"C:\Folder\ZipFileName.zip"))
{
archive.Password = "passwprd";
archive.Encryption = EncryptionAlgorithm.PkzipWeak;
archive.StatusMessageTextWriter = Console.Out;
archive.ExtractAll(#"C:\destinationFolder", ExtractExistingFileAction.Throw);
}
this code works fine in a console c# application, but i'm receiving the next error when I want to run my SSIS script....
en System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) en System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) en System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) en System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) en Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()
Any Idea ?

I think the issue is related to the DLL references, At runtime the SSIS package read the added assemblies from three locations by default:
The Global Cache Assembly
The .Net Framework folder
The SQL Server DTS Assemblies folder
You can refer to the following link for more details (check both answers)
Creating a reference to a custom assembly from an SSIS Script Task - vb

Related

Receiving error: Method 'FindIdentityResourcesByScopeNameAsync' does not have an implementation

I'm attempting to execute the following:
var builder = services.AddIdentityServer(
options => { options.IssuerUri = "https://boo.com"; })
.AddExtensionGrantValidator<LPDelegationGrantValidator>()
.AddProfileService<ONBProfileService>()
.AddOperationalStore(options =>
{
options.ConfigureDbContext = b =>
{
b.UseSqlServer(connectionString, db => db.MigrationsAssembly(migrationsAssembly));
};
})
.AddConfigurationStore(options =>
{
options.ConfigureDbContext = b =>
{
b.UseSqlServer(connectionString, db => db.MigrationsAssembly(migrationsAssembly));
};
});
This used to work but then I moved the solution to a different location and renamed some of my projects. Now it's crashing with the the following error.
I've tried aligning the versions of the packages I'm referencing to v3.1.3 but it's not fixing this.
Is there a straight-forward way to resolve this?
System.TypeLoadException
HResult=0x80131522
Message=Method 'FindIdentityResourcesByScopeNameAsync' in type 'IdentityServer4.EntityFramework.Stores.ResourceStore' from assembly 'IdentityServer4.EntityFramework.Storage, Version=3.1.3.0, Culture=neutral, PublicKeyToken=f294d0afe402bb2b' does not have an implementation.
Source=IdentityServer4.EntityFramework
StackTrace:
at Microsoft.Extensions.DependencyInjection.IdentityServerEntityFrameworkBuilderExtensions.AddConfigurationStore[TContext](IIdentityServerBuilder builder, Action`1 storeOptionsAction)
at Microsoft.Extensions.DependencyInjection.IdentityServerEntityFrameworkBuilderExtensions.AddConfigurationStore(IIdentityServerBuilder builder, Action`1 storeOptionsAction)
at IdSrv_Host_Console.Startup.GetSqlConfigurationBuilder(IServiceCollection services) in C:\Workspace\dev\live-person-sts-id4\IdentityServer4\Bupa_src\Idsrv_Host_Console\Startup.cs:line 75
at IdSrv_Host_Console.Startup.ConfigureServices(IServiceCollection services) in C:\Workspace\dev\live-person-sts-id4\IdentityServer4\Bupa_src\Idsrv_Host_Console\Startup.cs:line 49
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.<Invoke>g__Startup|0(IServiceCollection serviceCollection)
at Microsoft.AspNetCore.Hosting.StartupLoader.ConfigureServicesDelegateBuilder`1.<>c__DisplayClass15_0.<BuildStartupServicesFilterPipeline>g__RunPipeline|0(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.<Build>b__0(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.StartupLoader.ConfigureServicesDelegateBuilder`1.<>c__DisplayClass14_0.<ConfigureServices>g__ConfigureServicesWithContainerConfiguration|0(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
I faced the same issue when refactored my solution and extracted my DbContext into a separate project. This GitHub issue discussion helped me to fix that: Check that IdentityServer4.EntityFramework.Storage v3.1.3 is installed.
As you mentioned in your question you've already did that but in my case I had different versions in the original ASP.NET application and in the project I've extracted my DbContext to - there NuGet package was resolved with the latest v4.0.2 which caused incompatibility and runtime exception.
Hope that will help!

SSIS upgrade from 2008R2 to 2017 - script task fails when connecting to OLEDB data source

I'm in the process of upgrading a data warehouse from SQL Server 2008R2 to 2017. After the upgrade, every script task is throwing the same error trying to connect to a logging database.
The task connects to a database via an OLEDB connection manager, then writes some meta data to a logging table. It's failing on making the initial connection. I'm hoping it's a fairly simple invocation error, but I'm a SQL guy, not a VB guy, and I'm not seeing the issue.
I found this question, Missing library to reference OLEDB connection types, but the script isn't invoking the AcquireConnection() method, so I don't think it's applicable. Or if it is, I'm not seeing how.
This is the code, through the point of failure.
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.Data.OleDb
Imports System.Collections
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
<Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute> _
<System.CLSCompliantAttribute(False)> _
Partial Public Class ScriptMain
Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
Enum ScriptResults
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
End Enum
Public Sub Main()
Dim fireAgain As Boolean
Dim pkgExecVar As Variables
Dim cm As ConnectionManager
Dim cmParam As IDTSConnectionManagerDatabaseParameters100
Dim conn As OleDb.OleDbConnection
Dim cmd As OleDbCommand = New OleDbCommand()
pkgExecVar = Nothing
cm = Dts.Connections("Configuration_Metadata_Logging")
cmParam = CType(cm.InnerObject, IDTSConnectionManagerDatabaseParameters100)
conn = CType(cmParam.GetConnectionForSchema(), OleDb.OleDbConnection)
When I step through the code, the second line from the bottom throws an exception.
cmParam = CType(cm.InnerObject, IDTSConnectionManagerDatabaseParameters100)
System.InvalidCastException
HResult=0x80004002
Message=Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSConnectionManagerDatabaseParameters100'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{624862CB-55F9-4A92-965F-62BC4935296A}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
If there's anything else I can add to the question to help, please let me know.
EDIT: The OLEDB connection manager is using SQLNCLI11.1. Other components of the package (Execute SQL & Dataflow Tasks) are able to connect successfully.
EDIT II: In order to make this more searchable, here's the initial error the package throws, before adding a breakpoint to the script task and stepping through it.
Exception has been thrown by the target of an invocation.
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()
Update. I found the source of that code, and it's a blog post by Matt Mason called Accessing OLEDB Connection Managers in a Script. It's still undocumented and probably got broken some time between SQL 2008 and 2017.
The supported ways to do this are documented here: Connecting to Data Sources in the Script Task
The only ways to get a System.Data.OleDbConnection in a script task are
1) To use an ADO.NET Connection Manager and configure it to use the ADO.NET Provider for OleDb, like this:
Dim cm As ConnectionManager = Dts.Connections("Configuration_Metadata_Logging_adonet_oledb")
Dim conn As OleDb.OleDbConnection = CType(cm.AcquireConnection(Nothing), OleDb.OleDbConnection)
2) Use an OleDb Connection Mamanger and use its ConnectionString to create a new OleDbConnection (which you are also responsible for closing in your Script task). Like this:
Dim cm2 As ConnectionManager = Dts.Connections("Configuration_Metadata_Logging_oledb")
Using conn2 As New OleDb.OleDbConnection(cm2.ConnectionString)
conn2.Open()
End Using

SQL Server 2012 SSIS Script Task for sending mail from Gamil to Gmail , showing "DTS Script :Runtime Error"

I am using SSIS 12, SQL Server 2012, Visual Studio 2012 and .net 4.
My SSIS script task code(for sending mail):
// Introduction to the script task
/* The Script Task allows you to perform virtually any operation that can be accomplished in
* a .Net application within the context of an Integration Services control flow.
*
* Expand the other regions which have "Help" prefixes for examples of specific ways to use
* Integration Services features within this script task. */
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;
namespace ST_20fdf0b00e2949fda158e6680c127473
{
public void Main()
{
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential("raihanuahmed#gmail.com", "password");
MailMessage msg = new MailMessage();
msg.From = new MailAddress("raihanuahmed#gmail.com");
msg.To.Add(new MailAddress("raihan.csse.aiub#gmail.com"));
msg.Subject = "AW2012 ETL Process Complite";
msg.Body = string.Format("{0} records loaded into DimProduct", 0);
smtp.Send(msg);
Dts.TaskResult = (int)ScriptResults.Success;
}
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
}
}
After executing this email sending script, I am always getting
"DTS Script :Runtime Error"
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[]
arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,
Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags
bindingFlags, Binder binder, Object target, Object[] providedArgs,
ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParams)
at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()
I have uploaded my problem into Youtube here is the link:
DTS Script :Runtime Error
Here is my project link in Dropbox:
EmailScript
I have found the solution :) Many Many thanks to Mr.Nick.McDermaid ......
solution is :
Change account access for less secure apps https://support.google.com/accounts/answer/6010255

Application Crash issue in WPF application in MVVM architecture

Recently, we are facing crash issue's in our application(Not on regular basis, generally on the client side) and we are not able to track the reason for the error. Most of the time the error that we get from the log is something like this ..
Type : System.IndexOutOfRangeException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : Index was outside the bounds of the array.
Source : mscorlib
Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : Void Add(T)
HResult : -2146233080
Stack Trace : at System.Collections.Generic.List`1.Add(T item)
System.ComponentModel.BackgroundWorker.OnRunWorkerCompleted(RunWorkerCompletedEventArgs e)
at System.ComponentModel.BackgroundWorker.AsyncOperationCompleted(Object arg)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
Also in order to handle the crash at the application level, we have written certain code in App.xaml.cs file i.e.
private void CurrentDomain_UnhandledException(object sender,
UnhandledExceptionEventArgs e)
{
try
{
var exception = (Exception) e.ExceptionObject;
ExceptionHandler.HandleException(exception);
WpfMessageBox.Show(LocalizationManager.GetValue("AppErrorUnhandledException").ToString(),
LocalizationManager.GetValue("AppErrorUnhandledException").ToString(),
WpfMessageBoxButtons.OK,
WpfMessageBoxIcon.Error);
}
Is there anything we need to do besides this in order to stop the application to crash suddenly?
Note: Our application is based on MVVM pattern, concept such as service facade, unity, service orchestration, MutiThreading(Use of Background for calling service async)
P.S: Normally as per the logs, we are getting this error while caching the data.
Your CurrentDomain_UnhandledException will handle exceptions from Dispatcher, the UI thread.
BackgroundWorker is another thread, any exception occurs in this thread is not handled by the Dispatcher, and your system crashes.
You should handle the IndexOutOfRangeException inside the correct thread, the background one.
ng-HT

Silverlight 4 & WCF Deseralizing Issue- There was an error deserializing the object of type 'T'. Unexpected end of file

I have come across a large issue that i am having that has suddenly come to light when i upgraded my Silverlight & Web Projects to versions 4 respectively.
Since doing this, all my WCF Services are Failing with the following Error message:
There was an error deserializing the object of type Anyboat.Admin.UserService.User. Unexpected end of file. Following elements are not closed: LastName, AuthenticateUserResult, AuthenticateUserResponse, Body, Envelope.
The StackTrace is:
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, String action, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeReply(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.ProxyOperationRuntime.AfterReply(ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
at Anyboat.Admin.UserService.UserServiceClient.UserServiceClientChannel.EndAuthenticateUser(IAsyncResult result)
at Anyboat.Admin.UserService.UserServiceClient.Anyboat.Admin.UserService.UserService.EndAuthenticateUser(IAsyncResult result)
at Anyboat.Admin.UserService.UserServiceClient.OnEndAuthenticateUser(IAsyncResult result)
at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)
I put a breakpoint in my SilverlightFaultBehaviour on the Response Message and this is the Envelope reponse i got back. Notice the Carriage return which is between *"\r\n"*
"<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\">\r\n <s:Header>\r\n <a:Action s:mustUnderstand=\"1\">urn:UserService/AuthenticateUserResponse</a:Action>\r\n <a:RelatesTo>urn:uuid:07cc1361-c74c-4449-b423-e982d2ac8e05</a:RelatesTo>\r\n </s:Header>\r\n <s:Body>\r\n <AuthenticateUserResponse>\r\n <AuthenticateUserResult xmlns:d4p1=\"http://schemas.datacontract.org/2004/07/AnyBoat.Web.Classes.DataObjects\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n <d4p1:Active>true</d4p1:Active>\r\n <d4p1:EmailAddress>robbie#robbietapping.com.au</d4p1:EmailAddress>\r\n <d4p1:FirstName>Robbie</d4p1:FirstName>\r\n <d4p1:IsAdministrator i:nil=\"true\" />\r\n <d4p1:LastName>Tapping</d4p1:LastName>\r\n <d4p1:Password>xxxxxxxxx</d4p1:Password>\r\n <d4p1:UserID>2</d4p1:UserID>\r\n <d4p1:UserName>robbietapping</d4p1:UserName>\r\n </AuthenticateUserResult>\r\n </AuthenticateUserR
esponse>\r\n </s:Body>\r\n</s:Envelope>"
Can anyone tell me if there is away around this at all, i upgraded my VS2010 to SP1 where this has started to show itself.
Any Information or answers would be greatfully appreciated.
Thanks
EDIT
The Code that the Error Occurs on is:
public Anyboat.Admin.UserService.User EndAuthenticateUser(System.IAsyncResult result) {
object[] _args = new object[0];
Anyboat.Admin.UserService.User _result = ((Anyboat.Admin.UserService.User)(base.EndInvoke("AuthenticateUser", _args, result)));
return _result;
}
Which serialization type do you use at services side? I'm pretty sure that you use some custom serialization. "\r\n" problem is pretty common and it occurs when you're trying to deserialize not well formed xml received from service.
So I see two ways:
The most preferable way. Check the serializer at service side. It's obvious that service returns xml in wrong format.
Add IClientMessageInspector to client and remove special symbols from response before deserialization.

Resources