Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Back in the days of VS2008 I created a very large C# solution that included 12 projects.

When I added a reference to xyz.tlb to a given project, VS2008 automatically created a DLL interop.xyz.dll and things were great. All the
C#
using xyz;
statements were cool

These days, with vs2015, this is no longer seems to be the case.

Can anyone shed some light on what I'm missing here?

What I have tried:

* Deleting and re-adding the tlb reference.

* Finding a copy of interop.xyz.dll, placing it in a common location and adding a reference to it. What I hate about this is that if I upgrade product xyz and xyz.tlb is updated, my solution won't be up to date. Theoretically, by COM rules it ought to be backward compatible, but some vendors haven't always played nice.
Posted
Updated 30-Nov-16 3:32am

1 solution

I do not know how it was in VS2008 and why it changed, however there are two ways to deal with COM DLLs...
How to: Generate Interop Assemblies from Type Libraries[^]
How to: Add References to Type Libraries[^]
 
Share this answer
 
Comments
MikeTheFid 30-Nov-16 10:10am    
First, thank you for your response.

This is very weird. (context: VS2015)

If I do an Add Reference for xyz.tlb in project A (exe project), it adds the reference and the interop.xyz.dll is created in the obj... folder AND the Reference Property "Embed Interop Types" appears.

Repeating the exact same steps for project B (lib project), it adds the reference but flags it as an issue in Solution Explorer (an icon overlay appears) and the interop.xyz.dll is not created and Reference Property "Embed Interop Types" is not shown.
Kornfeld Eliyahu Peter 30-Nov-16 12:54pm    
It sounds like a problem with the tlb/lib file...
Try to build the interop manually, using tlbimp. It may give some clue...
MikeTheFid 2-Dec-16 10:01am    
Quick update out of respect for your efforts to help and anyone happening upon this thread.

If adding a reference to xyz.tlb to Project A works, and repeating the process for Project B in the same solution fails, I am inclined to believe the contents of tlb isn't the issue.

I decided to use the workaround of placing interop.xyz.dll in a non-"obj\..." fixed common location and adding a reference to the dll instead of the tlb. Not pretty but I just can't use any more time diagnosing this issue at this time.

Also, this problem results in the following IntelliSense errors:

* Error CS0006: Metadata file '<path>' could not be found
Where: <path> is the project dll that references the interop dll

* Error CS0246 The type or namespace name '<namespace>' could not be found (are you missing a using directive or an assembly reference?)
Where: <namespace> is XYZ (supposed to be backed by interop.xyz.dll)

Again, thank you. Your responses are much appreciated.
Kornfeld Eliyahu Peter 3-Dec-16 11:50am    
The DLLs you use are some common we can test too, or home made?
Can you recreate the bug with any two DLLs (like Office)?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900