Question

how to add COM .dll to .NET project and then use it without registering in GAC. The background is that I am not allowed to install anything on TFS building server and my application references COM dll component. How should I add COM to my app to reference is from bin/define folder not from GAC?

Edited:

when I am adding COM by Add Reference and Browse to DLL I got error "A reference to (...) could not be added. Please make sure that the file is accessible, and it is a valid assembly or COM component."

Thanks, Leszek

Was it helpful?

Solution

COM DLLs do not get installed into GAC. Primary Interop Assemblies (PIAs) do, but I don't think that's what you need. On what machine are you getting this message? You're getting it because your COM DLL is not registered as COM server (with regsvr32.exe). That has nothing to do with GAC. Once you have registered it on your development machine, you'll be able to add it as a reference to your .NET project. Adding it will generate the required interop assemblies, but they still will be local to your project, you don't have to install them into GAC.

Alternatively, you could use tlbimp or aximp tools and generate the interop assmeblies manually, then add them to the project.

Whatever option you take, the COM DLL still has to registered on your development machine, but it doesn't have to be so on the TFS build machine. More, you could use Isolated COM to avoid the registration requirement on the client machine. All you'd need then is to have the COM DLL and its interop assemblies residing in the same folder with your main application.

OTHER TIPS

Have you tried approach described in http://msdn.microsoft.com/en-us/library/ms973913.aspx ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top