views:

425

answers:

2

I have to register multiple assemblies to GAC using InstallSheild and also I need the assemblies to be copied on the INSTALLDIR also. What's the best way to do it? Also I need to call regasm.exe for an assembly; can I do this using InstallShield?

I really need a new 'component' for each assembly that has to be registered in GAC?

A: 

Yes. As far as the system cares, those are two different files. AFAIK, you can't have a file in the GAC and have it be in a random folder on the target computer at the same time.

Theoretically, if it's in the GAC, you don't need it in the product directory. If it's in the GAC, that will be the version loaded, not the one in the product directory. However, it gets harder if you need to, say, register it for COM interop too. I may be wrong, but when I tried, I had to have both: one in the directory, one in the GAC.

But really, you probably don't need it in the GAC if you need it in the product directory. If it's being loaded from any program anywhere, always, then the GAC is a decent place for it. If you're putting it in the GAC For COM interop, that's unnecessary; registering it by pointing it to the folder that you've installed it will work fine if you have installshield configured correctly.

Robert P
I developed a windows toolbar in C#. In this case the dlls should be in GAC, right?
Cornel
Not necessarily. If the consumers of your toolbar use it in their application, then they only need it in the folder of your application.
Robert P
+1  A: 

This answer assumes you are using a Windows Installer proeject type.

1) Create a component for each DLL, make it as the keyfile and set the destination folder to GlobalAssemblyCache. This instructs Windows Instlaler to use the MsiPublishAssemblies standard action which in turn makes calls into Fusion to register the assembly in the GAC. This is effectively what GACUTIL does for you. Remember: GACUTIL is not redistributable. If the assembly has companion files add them as companion files to the same component.

2) If your assembly is ComVisible, create a component for each DLL, mark it as the keyfile and set the .NET ComInterop to true. This will cause the COM information to be extracted at build time, and tell windows installer to use the MsiPublishAssemblies standard action to write the information to the registry. Note: If you have custom user code in the registration section of the assembly this will not be captured. This is per MSDN that regasm /regfile does not execute this code path. You will have to manually enter this information into InstallShield's registry view for that component.

3) Yes you can deploy a strong named assembly both globally and/or privatly. Whether the private one will be seen or not depends on whether the assembly with the reference has UseSpecific set or not.

Christopher Painter