views:

135

answers:

1

I'm trying to add the ActiveX Microsoft Excel 11.0 Object library to my .NET project. It works fine on my computer, but when I check in my code, it doesn't work on my coworker's. Fixed it on his and it broke mine. When added, the namespaces are different between our machines.

It turns out the difference is that when I add the reference it uses tlbimp as the WrapperTool, but for him it makes it a primary reference.

How do I make it work for both of us the same way? His machine doesn't like a tlbimp imported interop, and mine doesn't like a primary interop.

A: 

Hi,

we had a similar problem, and the option "tlbimp" worked on all computers.

My (imperfect) understanding is: .NET uses wrapper assemblies to access COM components. If you specify "primary", you use an existing, pre-generated "primary interop assembly". According to http://msdn.microsoft.com/en-us/library/hfac4fky.aspx, "primary interop assemblies are provided by the same publisher as the type library they describe". If using "primary" does not work for you, this assembly does not exist on your computer.

The default is "tlbimp" and (from what I gathered) should normally work. If it does not work on your coworker's machine, the error message would be helpful. Errors were reported for VS2003 (search for the KB article "You receive an error message when you add a reference to a COM object in Visual Studio .NET after you install Windows XP Service Pack 2"), but I do not know if this applies to current versions of VS.

If you cannot make this work, I would suggest that you could read more about "Primary Interop Assemblies" and try to find where the primary interop assembly for Excel is located on your coworker's machine, then copy it to the machines of all developers.

Hope this helps.

Ronald