How to Fix error Task could not find "sgen.exe" using the SdkToolsPath for v7.0a in VS2010

by Updated June 26, 2012

UPDATE 12-16-2011: For those of you who are getting an "sgen.exe" error message when trying to building your project in Visual Studio that reads something like "Could not load file or assembly or one of its dependencies. Operation is not supported. SGEN".  This is most likely due to a .dll in your solution that needs to be unblocked.  To do this go to the bin folder, right-click on a .dll file -> then in the Properties window, you will have the option to click the "Unblock" button (if the .dll is causing a problem).  Read more about this sgen .dll problem here.  (END)

I recently started using Visual Studio 2010 Express to build web application projects with Windows 7 (x64 bit computer).  When compiling the solution with the configuration set to Debug, I didn't have any problems.  However, once I set the solution to build to Release, I got the following sgen.exe not found error:

Task could not find "sgen.exe" using the SdkToolsPath "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\" or the registry key 

"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A". Make sure the SdkToolsPath is set and the tool exists in the correct processor specific location under the SdkToolsPath and that the Microsoft Windows SDK is installed

I tried finding the "sgen.exe" application within the "Microsoft SDKs\Windows\v7.0a\bin\NETFX 4.0 Tools\" directory and could not find it, nor anywhere else on my computer.  I also tried downloading the Windows SDK version 7.0, but that installed v7.0 (not v7.0a) and didn't solve the problem.  My computer seemed to be missing a bunch of Windows SDK file information for the v7.0a version.  Inevitably, after lots of head scratching here's what I did to fix the "sgen.exe" not found error in Visual Studio 2010:

  1. I downloaded and installed the latest SDK (as of this post) Windows SDK v7.1 for Windows 7.
  2. I then went to the following directory: C:\Program Files\Microsoft SDKs\Windows\v7.1\Setup and opened the WindowsSdkVer application, and in the Windows SDK Configuration Tool pop-up box, changed the  Installed Windows SDK Versions drop down box to v7.1 and then clicked the Make Current button. I then got a message box that says "The Windows SDK Configuration Tool has successfully set Windows SDK version v7.1 as the current version for Visual Studio 2008"  ( I have Visual Studio 2008 installed on my computer).   Unfortunately, making this change did not stop the Release build "sgen.exe" not found errors from occurring in Visual Studio 2010.
  3. So what I did was copied the v7.1 sgen.exe application file located at C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\NETFX 4.0 Tools\sgen.exe and the pasted it in to the v7.0a directory at C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\
    • Since my computer is running 64bit Windows 7, you'll notice that C:\Program Files  for 64bit progam files and C:\Program Files (x86) is for 32bit files, but so far this difference wasn't an issue.
  4. After copying the v7.1 sgen.exe over to the v7.0a directory that was listed in the error message that I got above, I was able to successfully build my VS2010 website project in Release mode and successfully build the deployment package.

That's what did the trick for me, and got things to build successfully in Visual Studio 2010!

If that didn't work for you, then the one other thing that I tried that also worked for me was to change the Build settings for "Generate serialization assembly" to Off in my VS2010 project. 

  1. Open your project in Visual Studio 2010, and then Right-click on your project file and select Package/Publish Settings.
  2. Then click on the Build tab and scroll down to the Output section.
  3. Change the Generate serialization assembly from "Auto" to "Off"
  4. Save your settings and try building your project.

By turning off the Generate serialization assembly, I was also successfully able to build my project without getting the "sgen.exe" not found error.  However, you will need to investigate whether turning off Generate serialization assembly will affect other parts of your project (I'm not sure if it will or not). 

So those were the two solutions that were able to get me past the "sgen.exe" not found error for the Windows SDK "v7.0a". 

 


0
6

6 Comments

anonymous by Craig Kelsall on 6/16/2010
I encountered the same issue on a dedicated build machine that uses MSBuild 4.0. The MSBuild ToolsVersion registry keys for 4.0 are pointing to v7.0a rather than v7.1. Altering the respective key values resolved the issue for me. Did v7.0a even exist?

This is the path to the registry keys:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0
anonymous by Dean Thomas on 6/22/2010
Fixed my issues, thanks.

Craig, v7.0a from what i've read, is a release purely from VS 2010, it's like MS want you to buy *another* license just to have a build server.
anonymous by Ray Powell on 10/18/2010
worked for me! thanks!
anonymous by ommo on 11/1/2010
it works for me, thnkx!
anonymous by Peter Gfader on 8/3/2011
I fixed it by creating a symbolic link from v7.0A to the right directory v7.1

cd C:\Program Files (x86)\Microsoft SDKs\Windows\
mklink /d v7.0A "c:\Program Files\Microsoft SDKs\Windows\v7.1"
anonymous by Rix on 11/9/2011
Copying the sgen.exe file worked well. Thanks

Add your comment

by Anonymous - Already have an account? Login now!
Your Name:

Comment:
Enter the text you see in the image below
What do you see?
Can't read the image? View a new one.
Your comment will appear after being approved.

Related Posts


Here's how to install Internet Information Services (IIS7) on a Windows 7 (or Vista) computer so that ASP.NET websites will run on the IIS7 web server. First, you will want to make sure that you are signed into an account with Administrator access on your...  more »

After running a ASP.NET website on IIS 7.5 for the first time on a Windows 7 computer, I was faced with the following error message: Login failed for user 'IIS APPPOOL\ASP.NET v4.0'. Description: An unhandled exception occurred during the execution of the...  more »

After setting up a new Windows 7 computer with IIS 7.5 and Visual Studio 2010, I tried to start my ASP.NET 4.0 website using the Local IIS web server. However, right off the bat I was hit with the following IIS error message: HTTP Error 500.21 - Internal...  more »

If you've recently moved a Visual Studio.net web site project (wsp) or web application project(wap) to deploy on Internet Information Services 7 (IIS7) you may have discovered that your Tiny_MCE text editor no longer is showing up and getting the pop-up...  more »