views:

33

answers:

2

I am trying to extend a certain application. I am using a DLL which comes bundled with that application to extend its functionality. I am using visual studio 2010 express edition. I added a reference to the dll library. In the refrence properties the option "Copy local" is disabled.(greyed out) why is that? I want visual studio to copy the dll to my release folder. If this can't be done is there anothter way to bundle the dll?

+2  A: 

It depends on what kind of DLL it is. If it is a COM server then Copy Local is off when you have a PIA registered for that COM server. If it is a regular .NET assembly then it will be off when it is registered in the GAC.

Fix the issue by, respectively, using regasm /u to unregister the PIA or gacutil /u to remove it from the GAC. Do note that you might not want to do this if this DLL requires that its installer is executed on the target machine. Which is likely. Talk to the component vendor or author to find out what you should do.

Hans Passant
It is a COM assembly (I can see it listed under the COM tab in visual studio add refrence add refrence dialog). how do I find the path of the assembly that I need to provide to regasm. The path displayed next to it within visual studio is project\obj\x86\Release\Interop.lbname.dll . Providing that path does execute successfully, but I still have the same problem.
Hard to make sense of that. project\obj\x86\release is not a valid path for an interop assembly. Nor should that show up in the Add Reference dialog. And you don't use regasm.exe on a native COM server, only on one that was implemented in .NET. In which case you should use it as-is, not as a COM server. Talk to your vendor.
Hans Passant
A: 

Your comment to Hans answer indicates this is a COM assembly and that you are using Visual Studio 2010.

This means the assembly reference was likely added with the "Embed Interop Types" setting set to true. This has the effect of linking the COM assembly into your binary removing the need to deploy it altogether. The following link has a more detailed explanation

If you do want to deploy it though then will need to do the following

  • Click on the reference in the references tab
  • Hit F4 to bring up the properties grid
  • Set "Embed Interop Types" to False (this will ungray Copy Local)
  • Set "Copy Local" to true
JaredPar
Thanks, that worked when I set embed interop types to false the copy local option automatically enables.