TlbExp.exe错误:该组件由一个运行时更新的建组件、错误、TlbExp、exe

2023-09-07 15:53:58 作者:花开终落,

我们正朝着我们的服务器的一部分,.NET 4.0。我们已经做了迁移到VS2010作为第一步,但并没有改变任何项目的目标框架。

We are moving part of our server to .net 4.0. We already did the move to Vs2010 as a first step but did not change the target framework of any project.

第二步,我把我们的服务器对目标4.0的特定部分,所以我们可以使用一些新的功能。

As a second step I'm moving a specific part of our server to target 4.0 so we can use some of the new functionality.

我在一个类库DLL,它的目标4.0呼吁TLBexp.exe时遇到问题。这个DLL还引用了很多针对2.0的DLL。

I've run into a problem when calling TLBexp.exe on a Class library DLL that targets 4.0. This DLL also references a lot of DLLs that target 2.0.

我得到的错误:TlbExp:错误TX0000:无法加载文件或程序集文件:Library.dll或它的某一个依赖。这个组件由一运行时间比当前加载运行时更新的构建并不能装载。

I get the error: TlbExp : error TX0000: Could not load file or assembly 'file:Library.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

我打电话随附TLBExp:微软的SDK \的Windows \ v7.0A \ BIN \ 在我在VS2010命令提示符下调用命令我引用v4.0.30319二进制文件(如mscorlib.tlb)

I am calling the TLBExp that comes with: Microsoft SDKs\Windows\v7.0A\bin\ In the command I call in the VS2010 command prompt I reference v4.0.30319 binaries (such as mscorlib.tlb)

是一个4.0 DLL引用2.0库运行TLB允许? 如果是的话那么任何理由,我得到这个错误。

Is running TLB on a 4.0 DLL that references 2.0 libraries allowed? If yes then any reason why I'm getting this error.

下面是确切的命令调用我用:C:\ Program Files文件\微软的SDK \的Windows \ v7.0A \ BIN \ tlbexp.exe/静音/ win32的/tlbreference:"C:\Windows\Microsoft.NET \框架\ v4.0.30319 \ mscorlib.tlb/tlbreference:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.tlb/tlbreference:"C:\Windows\Microsoft.NET\Framework\v4 .0.30319 \ System.Windows.Forms.tlb/tlbreference:"C:\Windows\system32\stdole2.tlbC:\开发\ Library.dll

Here is the exact command call i use: "C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\tlbexp.exe" /silent /win32 /tlbreference:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.tlb" /tlbreference:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.tlb" /tlbreference:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Windows.Forms.tlb" /tlbreference:"C:\Windows\system32\stdole2.tlb" C:\Dev\Library.dll

感谢

推荐答案

我有目标4.0的组件,则引用其中有3.5的目标框架的另一个组件。

I had an assembly targeting 4.0, that referenced another assembly which had a target framework of 3.5.

这样一来,我得到一个后生成的步骤同样的错误。通过反复试验,我发现TLBExp的版本,此文件夹中找到: C:\ Program Files文件(x86)的\微软的SDK \的Windows \ v7.0A \ BIN \ NETFX 4.0工具\ 能成功地生成TLB文件。

As a result, I was getting the same error on a "post build" step. By trial and error, I discovered that the version of TLBExp found in this folder: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\ could generate the TLB file successfully.

心连心!