I have two projects in a solution - say, ProjectA and ProjectB. Both projects are registered for COM interop, and ProjectA references ProjectB - when ProjectA builds, it copies ProjectB.dll into its output folder.
Now, the COM client needs to access ProjectB.tlb. I tried using a post-build event to xcopy the type library from ProjectB's output folder into ProjectA's; at a glance, this works - the COM client can "see" the types in the .tlb.
The problem is that the whenever the COM client tries to call a method in the .tlb, an automation error ensues.
My gut-feeling was that the .tlb needed to be created/registered in the location it's being used from, so I unchecked the "register for COM interop" box in ProjectB, removed the xcopy from the post-build events, and added a regasm.exe /tlb call in ProjectA's post-build events, so as to create and register ProjectB.tlb in the output folder of ProjectA... and then I cleaned and rebuilt the solution.
Same thing: the COM client sees the types, but throws an automation error when it tries to actually consume the exposed API.
The two projects were originally one and the same. We decided to split them so that when we ship an update of ProjectA, we could do so without causing compatibility issues with COM clients referencing the code in ProjectB. The idea seemed very good, but ...is it even possible? If so, how?
Or is folding ProjectB back into ProjectA my only hope to get the COM client to work with the COM API exposed by ProjectB?