4

I'm trying to use the Microsoft Shell Controls And Automation COM object library (C:\Windows\System32\shell32.dll) from within an SSIS Script Task to manipulate .zip archives.

Unfortunately, although I have successfully added the relevant Reference and the Script Task compiles OK. I'm using VB.NET, for what it's worth. I get the following runtime error as soon as I try to create any objects defined within the library:

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

I thought the Interop DLL would all be taken care of for me - does anyone know what step am I missing?

Jez Walters
  • 43
  • 1
  • 4

1 Answers1

3

SSIS needs all .dll references to be registered with the GAC, you are correct.

You have different options regarding installing this dll into the GAC:

  1. Drag and drop the .dll into the %windir%\assembly\ folder.

  2. Use the gacutil.exe you are thinking about using: Regarding installing into the GAC using the gacutil, there is alot of useful information here: Global_Assembly_Cache. Basically, if you have the .NET framework installed (you are using VB.NET so no problem there), you will have a gacutil.exe in your Microsoft.NET folder.

  3. (What I normally use when all else fails) Create a windows MSI project in Visual Studio that automatically does all this for you, useful info here: How to install assembly in the GAC using MSI

If you install that .dll in the GAC and you are still having problems, another option is to actually create a separate visual studio project that contains your logic for manipulating the needed zip files build it and call its exe from SSIS using the Execute Process Task. You can pass arguments specified in the SSIS package. Not very elegant, but it gets the job done if you are keen on using SSIS.


UPDATE:

The solution in this question did the trick SSIS Script Task COMException / FileNotFoundException error. The problem was in adding a signed reference of the dll, this answer provides a good step-by-step workaround for adding a COM reference within the SSIS Script Task.

Community
  • 1
  • 1
Milen Kindekov
  • 1,903
  • 1
  • 23
  • 31
  • What DLL do I need to put into the GAC? I've tried installing both "Interop.Shell32.dll" and "Shell32.dll", but neither worked. When I try to install the Interop.Shell32.dll that SSIS generates in its temporary folder, I'm told it doesn't have a strong name. Installing Shell32.dll fails because the module was expected to contain an assembly manifest. – Jez Walters Oct 31 '12 at 09:01
  • By the way, using Windows Explorer to install into the GAC via drag & drop doesn't work either, as I'm prevented from dropping files into the C:\Windows\assembly virtual folder (even when I run as adminstrator). – Jez Walters Oct 31 '12 at 09:09
  • I had to install the .NET Framework SDK in order to get gacutil too. – Jez Walters Oct 31 '12 at 09:12
  • Finally, unfortunately I can't explore go with your last suggestion as I don't have Visual Studio - only VSTA. :-( I suppose I could install Visual Studio Express, but it's rather a lot of effort for a simple archiving problem! – Jez Walters Oct 31 '12 at 09:51
  • By the way, I'm using .NET Framework 3.5 - so System.IO.Compression isn't an option either. – Jez Walters Oct 31 '12 at 09:53
  • @JezWalters I looked around, try this out (steps 2-10 of the answer) http://stackoverflow.com/questions/12965210/ssis-script-task-comexception-filenotfoundexception-error – Milen Kindekov Oct 31 '12 at 10:03
  • When I tried adding the Shell32 reference without having the project signed, it added an unsigned reference as well. The trouble is getting that signed Interop.Shell32.dll – Milen Kindekov Oct 31 '12 at 10:06
  • Good grief what a lot of hassle - but it worked in the end! Many thanks for your peseverance. – Jez Walters Nov 02 '12 at 10:02
  • Don't mention it, safe to say that it is not the most intuitive of functionalities. Glad it worked though! – Milen Kindekov Nov 02 '12 at 10:10