none
Mixing Interop Versions RRS feed

  • Question

  • We had a slew of old projects being built as C# VS2003. They referenced an old project that was un-managed C++ VS2003 and they did so by generating a RCW Interop file that was referenced by the C# projects. Recently, we updated to a new version of the called project, building it with C++ VS2008. Now when we generate a RCW the VS2003 projects cannot reference it, but I have had trouble locating information that explicitly says what the rules are on mixing versions like this. It is very late in our build cycle to update all of those VS2003 projects. Someone suggested using the VS2003 tlbimp to generate a RCW from the VS2008 binary, but if these are version incompatible I'd prefer not risking this sort of workaround.

    Can someone please tell me what the rules for using this are with different VS versions?
    Tuesday, November 17, 2009 2:16 PM

Answers

  • This isn't an interop issue, it's that a .NET 1.1 assembly cannot reference or load a 2.0 or later assembly. If you search for ".net 1.1 cannot reference 2.0 assemblies" you'll find many hits.  The suggestion to use tlbimp from VS 2003/.NET 1.1 to generate them sounds like a good idea to me. 
    Phil Wilson
    • Marked as answer by ShawnGarrison Wednesday, November 18, 2009 2:14 PM
    Wednesday, November 18, 2009 12:20 AM
  • They should be compatible. Interop assemblies are basically maps from C# to COM interfaces and methods and don't use the kind of contructs that get deprecated, IIRC.  If the COM interfaces are stable, some people write their own interop assemblies in C# so they can be compiled any any VS version you want. tlbimp reads the typlibrary info and generates everything. Reflector can reverse engineer it into C# for you.
    Phil Wilson
    • Marked as answer by eryang Friday, November 20, 2009 12:03 PM
    Wednesday, November 18, 2009 10:26 PM

All replies

  • This isn't an interop issue, it's that a .NET 1.1 assembly cannot reference or load a 2.0 or later assembly. If you search for ".net 1.1 cannot reference 2.0 assemblies" you'll find many hits.  The suggestion to use tlbimp from VS 2003/.NET 1.1 to generate them sounds like a good idea to me. 
    Phil Wilson
    • Marked as answer by ShawnGarrison Wednesday, November 18, 2009 2:14 PM
    Wednesday, November 18, 2009 12:20 AM
  • So if we generate all interop assemblies with 1.1 there will be no conflicts with later assemblies referencing them? They are completely backwards compatible?
    Wednesday, November 18, 2009 2:15 PM
  • They should be compatible. Interop assemblies are basically maps from C# to COM interfaces and methods and don't use the kind of contructs that get deprecated, IIRC.  If the COM interfaces are stable, some people write their own interop assemblies in C# so they can be compiled any any VS version you want. tlbimp reads the typlibrary info and generates everything. Reflector can reverse engineer it into C# for you.
    Phil Wilson
    • Marked as answer by eryang Friday, November 20, 2009 12:03 PM
    Wednesday, November 18, 2009 10:26 PM