Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Svcutil.exe for .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.

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?

like image 534
D.H. Avatar asked Apr 22 '10 13:04

D.H.


2 Answers

The latest version of the SDK for .Net 4.0 is available at

http://msdn.microsoft.com/en-us/windows/bb980924.aspx

svcutil.exe which resides in v7.1/bin has version 3.0.4506.2152.

svcutil.exe which resides in v7.1/bin/NETFX 4.0 Tools has version 4.0.30319.1.

like image 37
Sharken Avatar answered Oct 09 '22 02:10

Sharken


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..."

  • If you look in "Microsoft SDKs\Windows\v6.0A\Bin", you will see that the version of that exe is "3.0.4506.2152".
  • The version of SvcUtil.exe in "Microsoft SDKs\Windows\v7.0A\Bin" is exactly the same, so it threw me for a loop as well.

However, there is another version of SvcUtil.exe located in "Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools" which is version "4.0.30319.1", and if you use it, everything should work.

like image 144
Boris Avatar answered Oct 09 '22 00:10

Boris