My boss wants me to make our product available as a COM reference. I am trying to do a simplified version to get the concepts in my head, and I've run into an error.
Reproduction steps:
- Create new class library in visual studio (Create New Project -> Choose "Class Library (.NET Framework) Visual C#"
- Add public string to Class1, add ComVisible, Guid and ProgId attributes.
- Add new interface, which Class1 implements, which also gets Comvisible and Guid attributes.
- Open project properties, go to Build section and check 'Register for COM interop'.
- Rebuild.
- Open second instance of visual studio
- Create second project, once again choose 'Class Library (.NET Framework) Visual C#'.
- In second project click 'Add Reference', and then select the COM section of the Reference Manager.
- The project we built in step #5 will be present, attempt to add it.
An error message appears saying:
"A reference to 'Project1' could not be added.
The ActiveX type library "[path]\Project1.tlb' was exported from a .NET assembly and cannot be added as a reference.
Add a reference to the .NET assembly instead."
I've googled this error and checked around, and it appears to be visual studio's way of being 'helpful', and informing me that there exists a superior way to reference Project1 from Project2, namely a direct reference, since they are both part of the Framework.
My question, is there any way to get around this? That is, any way to tell visual studio 'I know you want to tell me a better way, but this is the requirement, just let me use COM?'.
If not, is there any way to get around this, maybe by creating another project which is not in the Framework, which can use COM to reference Project1, and itself be referenced through COM by Project2?
Thanks for your assistance.