在Visual Studio中禁止TLBimp警告 [英] Suppress tlbimp warnings in visual studio

查看:110
本文介绍了在Visual Studio中禁止TLBimp警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio C#项目中,可以添加对COM库的引用.然后,Visual Studio将使用 tlbimp.exe 来生成项目时生成互操作程序集.该引用在.csproj文件中如下所示:

In a visual studio C# project, it is possible to add references to COM libraries. Visual Studio will then use tlbimp.exe to generate the interop assembly when building the project. The reference looks like this in the .csproj file:

  <ItemGroup>
    <COMReference Include="TDAPIOLELib">
      <Guid>{F645BD06-E1B4-4E6A-82FB-E97D027FD456}</Guid>
      <VersionMajor>1</VersionMajor>
      <VersionMinor>0</VersionMinor>
      <Lcid>0</Lcid>
      <WrapperTool>tlbimp</WrapperTool>
      <Isolated>False</Isolated>
    </COMReference>
  </ItemGroup>

但是,我在这里导入的3rdparty类型库导致tlbimp发出一些警告.如何在Visual Studio中禁止显示这些警告?我试图将包装器工具更改为

However, the 3rdparty type library which I am importing here causes tlbimp to emit some warnings. How do I suppress these warnings in visual studio? I tried to change the wrapper tool to

  <WrapperTool>tlbimp /silent</WrapperTool>

但这会导致Visual Studio抱怨

but that causes visual studio to complain with

发生了一个错误 遇到妨碍参考的情况 正在加载"TDAPIOLELib".这 包装工具'tlbimp/silent'不是 有效的包装器工具.

An error has been encountered that prevents reference 'TDAPIOLELib' from loading. The wrapper tool 'tlbimp /silent' is not a valid wrapper tool.

推荐答案

我最终使用了BeforeBuild目标来显式调用tlbimp.exe:

I ended up using the BeforeBuild target to explicitly invoke tlbimp.exe:

  <Target Name="BeforeBuild">
     <Exec Command="tlbimp /silent ..\3rdparty\comlibrary.dll /out:..\bin\interop.comlibrary.dll" />
  </Target>

这确实需要引用interop.comlibrary.dll二进制文件,从而在第一次构建之前打开项目时,在Visual Studio中的引用上产生一个黄色警告标志.

This does require referencing the interop.comlibrary.dll binary, resulting in a little yellow warning sign on the reference in visual studio when opening the project before the first build.

这篇关于在Visual Studio中禁止TLBimp警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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