none
managed COM RRS feed

  • Question

  • I'm developing a .NET 2.0 application that now has to use a COM implemented in .NET that was use before in an application written in C++.
    When I'm trying to add the COM library as a reference to my project this error occurs: "ActiveX type libraray was exported from a .net assembly and cannot be added as a refference. Add a reference to the .NET assembly instead.."

    What should I do? The .NET COM must be redesigned now so that managed to managed to work?

    Regards
    Tuesday, August 26, 2008 2:13 PM

Answers

  • You'll need the 3rd party assembly to compile and test your code.  When you're ready to deploy, you omit that assembly.  Of course, test your code with the assembly missing.  When the 3rd party installs their assembly, they must put it in the GAC or put a copy of it in your .exe folder so your program can find it.  Since it was originally used as a COM component, it already should have a strong name so putting it in the GAC is the best solution.  Although the error message you quoted suggests it doesn't.  That's their mistake.
    Hans Passant.
    • Marked as answer by Cornel Gav Wednesday, August 27, 2008 9:40 AM
    Wednesday, August 27, 2008 8:11 AM
    Moderator

All replies

  • There's no point in using the COM interface.  Just use the assembly directly.  Project + Add Reference, Browse tab.
    Hans Passant.
    Wednesday, August 27, 2008 5:05 AM
    Moderator
  • I know that I could do this but the dll comes from a 3rd party application that might not be installed when I'm running my application.
    What should I do in this case?

    Thanks
    Wednesday, August 27, 2008 5:13 AM
  • Dynamically load the assembly (if it's installed) at runtime.
    Mattias, C# MVP
    Wednesday, August 27, 2008 6:17 AM
    Moderator
  • Or catch the exception you'll get when you try to create a type from it.  No different from the COM case.
    Hans Passant.
    Wednesday, August 27, 2008 6:52 AM
    Moderator
  • I have on dll installed with the 3rd party application. This dll has many references also. By default when I add it as a reference to my project 'Copy Local = true' and I don't want to be copied local. If I set 'Copy Local' to false I'm getting this error: Assembly 'Abc.dll' must be strong signed in order to be marked as a prerequisite.

    If 'Copy Local' is true I'll not get an exception when ttrying to create a Type, right?
    Can anyone give me an example of what I should do in this situation?

    Thanks



    Wednesday, August 27, 2008 7:23 AM
  • You'll need the 3rd party assembly to compile and test your code.  When you're ready to deploy, you omit that assembly.  Of course, test your code with the assembly missing.  When the 3rd party installs their assembly, they must put it in the GAC or put a copy of it in your .exe folder so your program can find it.  Since it was originally used as a COM component, it already should have a strong name so putting it in the GAC is the best solution.  Although the error message you quoted suggests it doesn't.  That's their mistake.
    Hans Passant.
    • Marked as answer by Cornel Gav Wednesday, August 27, 2008 9:40 AM
    Wednesday, August 27, 2008 8:11 AM
    Moderator