views:

1413

answers:

5

I am getting the following error when attempting to build my project in Visual Studio 2008 Professional Edition:

*Task failed because “sgen.exe” was not found, or the correct Microsoft Windows SDK is not installed. The task is looking for “sgen.exe” in the “bin” subdirectory beneath the location specified in the InstallationFolder value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0A. You may be able to solve the problem by doing one of the following: 1) Install the Microsoft Windows SDK for Windows Server 2008 and .NET Framework 3.5. 2) Install Visual Studio 2008. 3) Manually set the above registry key to the correct location. 4) Pass the correct location into the “ToolPath” parameter of the task.*

I tried downloading Microsoft Windows SDK for Windows Server 2008 and .NET Framework 3.5, and still get the error. I also tried downloading the Windows 7 SDK and .NET Framework 3.5 and still same result.

I also tried to manually editing the registry to change the InstallationFolder and I tried repairing the Visual Studio install.

The project was originally created on WinXP and I am trying to compile on a reformatted machine running Windows 7 Enterprise.

A: 

The problem appears to be caused by Visual Studio 2008 when using Web References. I ended up deleting the Web References and just used Service References.

I found a blog post about this posted here and here.

Kinze
+2  A: 

copy /y “C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sgen.exe” “C:\WINDOWS\Microsoft.NET\Framework\v3.5\”

See the explanation here:

Todd Price
A: 

This worked for me on Win 7 / VS.NET 2008:

The solution is: Download the Windows SDK and install .Net Development Tools (it says 2008 Server but I did this on XP SP3): http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=e6e1c3df-a74f-4207-8586-711ebe331cdc

Found it here, a post which includes a helpful screenshot of the minimal install of the SDK needed to fix this.

Todd Price
A: 

Thanks It worked :)

Krishna
A: 

On Win Server 2008 and fresh install of VS 2008, with a project originally created in VS2003 with a Web Reference, a comment on the page Todd Price linked to worked for me. In the project properties, under build, change configuration to 'All Configurations' and change 'Generate serialization assembly' to Off.

Ben Scott