1
votes

The application need to use COM reference Microsoft Shell Control And Automation, which is located at C:\Windows\system32\shell32.dll

But after adding its reference, VS 2010 added a dll Interop.Shell32.DLL in target build directory. Everything working fine. But when builing MSI setup wizard project. It adds shell32.dll as dependency. Alright, No problem.

But when install, it also copies shell32.dll along with Interop.Shell32.DLL in target installation directory, now when application runs it shows strange errors. But if I manually delete shell32 from installation directory, everything works fine.

Why MSI is copying shell32.dll in installation directory ? Is it required for 64-bit OS ? If yes, whyInterop.Shell32.DLL ? For my app, shell32.dll seems to be problem, Is there a way I can avoid it being copied ?

Edit:

I excluded shell32.dll from setup project, will it be problem in 64bit OS ?

Edit2: shell32.dll at C:\Windows\system32\ is actually 5KB but MSI copies 11 MB one. What is it ?

2

2 Answers

2
votes

You will definitely have to prevent your installer from copying shell32.dll. It is a critical operating system DLL that is always included with Windows. Having the wrong version of shell32.dll is a rather fatal problem. The file system protection feature built into Windows will prevent it from overwriting the one in c:\windows\system32, but it is powerless to stop a local copy from ruining your program. And yes, it is many megabytes, it only looks like it is installed in c:\windows\system32. That's actually a hard-link to the real location, it is stored in c:\windows\winsxs. Most files in system32 are actually hard links, otherwise a simple mechanism to prevent bad installers from destroying the operating system.

The Interop.Shell32.dll assembly is an interop assembly, generated by Tlbimp.exe. It only contains declarations with the [ComImport] directive, the ones retrieved from the type library inside shell32.dll and translated to equivalent .NET declarations. Gives the CLR an easy time to implement the RCW without it having to read the type library itself. You do have to deploy the interop assembly.

No idea what went wrong here, it certainly isn't normal for an installer creator utility to automatically also copy the native DLL for the interop assembly. But you do have to intervene and stop it from doing this.

1
votes

You could add reference and then set the properties of this reference

set copy local to False