Sql – Get FileNotFoundException error when call a ActiveX in SSIS script task

activexcomsql-server-2008ssis

I need call a ActiveX in my SSIS package, so I use script task and write the following C# script:

public void Main()
{
    clsAptFdbReader objFdbReader = new clsAptFdbReader("UnitedStates20000830.fdb");
    objFdbReader.OpenFdb(false);
    Dts.TaskResult = (int)ScriptResults.Success;
}

Get a error:

Error:
System.Reflection.TargetInvocationException:
Exception has been thrown by the
target of an invocation. —>
System.IO.FileNotFoundException: Could
not load file or assembly
'Interop.APTFDBReader,
Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null' or one of its
dependencies. The system cannot find
the file specified. File name:
'Interop.APTFDBReader,
Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null' at
ST_320325ad8e2543f09ee688d809f58ee7.csproj.ScriptMain.Main()

=== Pre-bind state information === LOG: User = SHINETECHCHINA\xugy LOG:
DisplayName = Interop.APTFDBReader,
Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null (Fully-specified)
LOG: Appbase = file:///C:/Program
Files/Microsoft SQL
Server/100/DTS/binn/ LOG: Initial
PrivatePath = NULL Calling assembly :
(Unknown).
=== LOG: This bind starts in default load context. LOG: Using application
configuration file: C:\Program
Files\Microsoft SQL
Server\100\DTS\binn\DtsDebugHost.exe.Config
LOG: Using machine configuration file
from
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to
reference at this time (private,
custom, partial, or location-based
assembly bind). LOG: Attempting
download of new URL file:///C:/Program
Files/Microsoft SQL
Server/100/DTS/binn/Interop.APTFDBReader.DLL.
LOG: Attempting download of new URL
file:///C:/Program Files/Microsoft SQL
Server/100/DTS/binn/Interop.APTFDBReader/Interop.APTFDBReader.DLL.
LOG: Attempting download of new URL
file:///C:/Program Files/Microsoft SQL
Server/100/DTS/binn/Interop.APTFDBReader.EXE.
LOG: Attempting download of new URL
file:///C:/Program Files/Microsoft SQL
Server/100/DTS/binn/Interop.APTFDBReader/Interop.APTFDBReader.EXE.

— End of inner exception stack
trace — at
System.RuntimeMethodHandle._InvokeMethodFast(Object
target, Object[] arguments,
SignatureStruct& sig, MethodAttributes
methodAttributes, RuntimeTypeHandle
typeOwner) at
System.RuntimeMethodHandle.InvokeMethodFast(Object
target, Object[] arguments, Signature
sig, MethodAttributes
methodAttributes, RuntimeTypeHandle
typeOwner) at
System.Reflection.RuntimeMethodInfo.Invoke(Object
obj, BindingFlags invokeAttr, Binder
binder, Object[] parameters,
CultureInfo culture, Boolean
skipVisibilityChecks) 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
System.Type.InvokeMember(String name,
BindingFlags invokeAttr, Binder
binder, Object target, Object[] args,
CultureInfo culture) at
Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()

Best Answer

You can generate the interop as part of your build using TLBIMP.EXE, and give it arguments to build a strong name.

I'm not sure if it's wise to install that interop into the GAC, though, if it's based on a third-party COM server?

Related Topic