Support multiple assembly versions
-
Hello, I have an application that references a particular assembly that contains the Windows Media Center Click-To-Record API (Windows\eHome\ehRecObj.dll). The problem is that when my application runs on Vista this assembly is version 6.0.6000.0 and when it runs on MCE 2k5 the version of this assembly is 5.1.2710.2732. My development machine is running Vista, so when I add a reference to this assembly to my project it's to the 6.0.6000.0 version. This results in my application crashing when I run it on MCE 2k5 with a "could not load file or assembly" exception because that particular version of that assembly does not exist on MCE 2k5. What do I need to do to my project so that my application will work with either version of the ehRecObj assembly? I've searched for documentation but since I don't understand assembly versioning very well I can't quite seem to find anything that answers my question.
Joseph LeBlanc
-
Hello, I have an application that references a particular assembly that contains the Windows Media Center Click-To-Record API (Windows\eHome\ehRecObj.dll). The problem is that when my application runs on Vista this assembly is version 6.0.6000.0 and when it runs on MCE 2k5 the version of this assembly is 5.1.2710.2732. My development machine is running Vista, so when I add a reference to this assembly to my project it's to the 6.0.6000.0 version. This results in my application crashing when I run it on MCE 2k5 with a "could not load file or assembly" exception because that particular version of that assembly does not exist on MCE 2k5. What do I need to do to my project so that my application will work with either version of the ehRecObj assembly? I've searched for documentation but since I don't understand assembly versioning very well I can't quite seem to find anything that answers my question.
Joseph LeBlanc
Hi! I guess ehRecObj.dll is hosting a COM type library, right? In order to support different versions I think the best way (at least the one I use) is to take the dll with the lowest version (that's still supporting the functionality you need) and create an interop assembly "by hand". There's a tool named "tlbimp" included in the .NET SDK that can create such interop assemblies. In your .NET application you only reference the interop assembly (instead of adding a reference to the COM type library). At runtime, the calls to your interop assembly's classes are marshaled to calls to the actual COM objects installed on the target system.
Regards, mav -- Black holes are the places where God divided by 0...
-
Hi! I guess ehRecObj.dll is hosting a COM type library, right? In order to support different versions I think the best way (at least the one I use) is to take the dll with the lowest version (that's still supporting the functionality you need) and create an interop assembly "by hand". There's a tool named "tlbimp" included in the .NET SDK that can create such interop assemblies. In your .NET application you only reference the interop assembly (instead of adding a reference to the COM type library). At runtime, the calls to your interop assembly's classes are marshaled to calls to the actual COM objects installed on the target system.
Regards, mav -- Black holes are the places where God divided by 0...
ehRecObj actually isn't COM, it's a managed API.
Joseph LeBlanc
-
ehRecObj actually isn't COM, it's a managed API.
Joseph LeBlanc
Oh, in that case you can specify (at least in VS 2005) that the reference doesn't require a specific version in the reference's properties.
Regards, mav -- Black holes are the places where God divided by 0...
-
Oh, in that case you can specify (at least in VS 2005) that the reference doesn't require a specific version in the reference's properties.
Regards, mav -- Black holes are the places where God divided by 0...
That's the kind of solution I'm looking for, I just can't figure out how to do it. I'm using Visual C# 2008 Express and I can't find any settings that let me configure how the assembly is referenced in my project. I looked at my .csproj file and where I reference that assembly there's a line "<SpecificVersion>False</SpecificVersion>". I've never changed that setting so I don't think that's the reason.
Joseph LeBlanc
-
That's the kind of solution I'm looking for, I just can't figure out how to do it. I'm using Visual C# 2008 Express and I can't find any settings that let me configure how the assembly is referenced in my project. I looked at my .csproj file and where I reference that assembly there's a line "<SpecificVersion>False</SpecificVersion>". I've never changed that setting so I don't think that's the reason.
Joseph LeBlanc
You see it's not easy trying to help you if every relevant piece of information has to be extracted bit by bit... I don't have any experience with VS 2008 yet, so I'm sorry I can't help you any further...
Regards, mav -- Black holes are the places where God divided by 0...