我正在使用TlbImp生成互操作程序集。我的几个类型库引用了一个核心类型库。
当我对First.dll运行TlbImp时,我得到了Interop.First.dll和Interop.Core.dll。问题是,当我针对Second.dll再次运行它时,TlbImp再次尝试生成Interop.Core.dll,导致错误:
TlbImp : error TI0000 : System.ApplicationException - The assembly for referenced
type library, 'Core', will not be imported since it would overwrite existing file
'Core.dll'.如何告诉TlbImp不要为引用的程序集生成互操作?
发布于 2012-08-09 04:21:44
我需要使用/reference参数来显式标识现有的互操作程序集。
最初我运行的是以下命令:
> tlbimp Core.dll /out:Interop.Core.dll
> tlbimp First.dll /out:Interop.First.dll
> tlbimp Second.dll /out:Interop.Second.dllTlbImp将在第二个和第三个命令中尝试导入引用的Core.dll并在Core.dll创建互操作,从而触发错误。
为了解决这个问题,我只需要显式地指定Core互操作:
> tlbimp Core.dll /out:Interop.Core.dll
> tlbimp First.dll /reference:Interop.Core.dll /out:Interop.First.dll
> tlbimp Second.dll /reference:Interop.Core.dll /out:Interop.Second.dllhttps://stackoverflow.com/questions/11872543
复制相似问题