这个问题是this question的续篇C#程序如何使用任何版本的COM DLL?
我们正在创建一个用C++编写的dll,提供对某些硬件的访问。这个DLL实现并使用COM接口访问。我们也有一个C#程序,它通过COM对象使用这个DLL。
我们遇到了版本问题。事实上,在运行C#程序时,它绝对要使用编译时使用的确切COM/C++ dll版本。即如果C#程序是使用COM/C++ dll 1.2.3.4编译的,那么程序将拒绝使用COM/C++ dll 1.2.3.5运行。
Unhandled Exception: System.TypeInitializationException: The type initializer for 'MyDllVerify.App' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'MyCorp.MyDll.Interop, Version=1.2.3.4, Culture
=neutral, PublicKeyToken=ced78d295d1e0f2b' or one of its dependencies. The system cannot find the file specified.
File name: 'MyCorp.MyDll.Interop, Version=1.2.3.4, Culture=neutral, PublicKey Token=ced78d295d1e0f2b' at MyDllVerify.App..cctor()
我想指示C#程序使用任何COM/C++ DLL版本1.2.anything。
我在哪里可以在C#项目中配置?