保持.NET项目中引用的COM dll的正确版本 [英] Maintain the correct version for a COM dll referenced in a .NET project

查看:163
本文介绍了保持.NET项目中引用的COM dll的正确版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在.NET项目中引用COM DLL,但我也想确保创建的Interop DLL具有正确的版本(以便修补程序知道DLL何时必须更改)。

I want to reference a COM DLL in a .NET project, but I also want to make sure that the interop DLL created will have the correct version (so that patches will know when the DLL must be changed).

如果我使用 TlbImp 我可以指定所需的版本与 / asmversion 标志,但是当我直接从Visual Studio添加它,它获得一个版本,与原来的COM DLL的版本无关。

If I use TlbImp I can specify the required version with the /asmversion flag but when I add it directly from Visual Studio it gets a version that has nothing to do with the original COM DLL's version.

我试图更改版本 .vcproj 档案

<ItemGroup>
    <COMReference Include="MYDLLLib">
        <Guid>{459F8813-D74D-DEAD-BEEF-00CAFEBABEA5}</Guid>
        <!-- I changed this -->
        <VersionMajor>1</VersionMajor> 
        <!-- This too -->   
        <VersionMinor>0</VersionMinor> 
        <Lcid>0</Lcid>
        <WrapperTool>tlbimp</WrapperTool>
        <Isolated>False</Isolated>
    </COMReference>
</ItemGroup>

但是随后项目无法构建,出现以下错误:

But then the project failed to build with the following error:


错误CS0246:无法找到类型或命名空间名称MYDLLLib(是否缺少using指令或程序集引用?)

error CS0246: The type or namespace name 'MYDLLLib' could not be found (are you missing a using directive or an assembly reference?)

有没有办法得到这个完成,而不是提前用 TlbImp 创建所有我的COM引用?

Is there any way to get this done without creating all my COM references with TlbImp in advance?

如果答案是,有没有办法指定一个内部版本号除了主要和次要版本? (例如1.2。 42 .0)

If the answer is yes is there a way to specify a build number in addition to the major and minor versions? (e.g 1.2.42.0)

推荐答案

Guid是指TypeLib的Guid直接DLL。版本号指的是TypeLib的版本而不是DLL。

The Guid refers to the Guid for the TypeLib not the DLL directly. The version numbers refer to the TypeLib's version not the DLLs.

版本号将来自您的idl文件,我相信它只支持主版本和次版本,而不是构建版本。

The version number will come from your idl file, and I believe it only supports a major and minor version and not a build version. Is this version changing when you modify the typelib?

版本号将出现在注册表中:

The version numbers will appear in the registry under:

HKEY_CLASSES_ROOT\Typelib\{typelib uuid}\Major.Minor

如果次要版本设置为0,那么我相信它将导入与主要版本匹配的最新版本,但主要版本必须设置为某些。

If the minor version is set to 0 then I believe it will import the 'latest' version that matches the major version, but the major version must be set to something.

这篇关于保持.NET项目中引用的COM dll的正确版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆