svcutil.exe的用于.NET 4.0?exe、svcutil、NET

2023-09-03 08:35:38 作者:青灯有味

我试图用svcutil.exe的生成代理类的服务,但是当我使用 /参考选项引用是专为.NET 4.0的组件我得到一个错误。

I was trying to use svcutil.exe to generate proxy classes for a service but when I use the /reference option to reference an assembly that is built for .NET 4.0 I get an error.

无法加载文件或程序[...]或它的一个依赖。这个组件由一运行时间比当前加载运行时更新的构建并不能装载。

Could not load file or assembly [...] or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

这样看来,我使用的是旧版本svcutil.exe的了。我使用了一个C:\ Program Files文件\微软的SDK \的Windows \ v7.0A 这是最新一期我能找到有更高版本的地方,我应该使用?

So it seems that I am using an old version of svcutil.exe. I am using the one in "C:\Program Files\Microsoft SDKs\Windows\v7.0A which was the latest one I could find. Is there a later version somewhere that I am supposed to use?

推荐答案

我有同样的问题。如果你的项目设置为使用.NET 4.0框架,你必须选择合适的版本svcutil.exe的,否则它会抛出一个错误:无法加载...

I had the same issue. If your project is set to use the .NET 4.0 Framework, you must choose the right version of SvcUtil.exe, or it will throw an error: "Could not load..."

如果你看一下微软的SDK \的Windows \ v6.0A \ BIN,你会看到那个exe文件的版本是3.0.4506.2152。 svcutil.exe的在微软的SDK \的Windows \ v7.0A \ BIN的版本是完全一样的,所以它扔我一个循环中使用。

不过,还有另一个版本svcutil.exe的的位于微软的SDK \的Windows \ v7.0A \ BIN \ NETFX 4.0工具,这是版4.0.30319.1,如果你使用它,一切应该工作。