在增加WebService引用時有可能會報錯:
錯誤 1 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. st_b66e0151399b4f378a4ca9a51f7c4840
這個報錯是因為默認會對WebService進行序列化,序列化時找不到"sgen.exe"導致。我在網上找到的方法是(參見:https://stackoverflow.com/questions/1302225/task-failed-because-sgen-exe-was-not-found)。但是我在我的項目中未找到對應的目錄。
我的解決方法是 :在程式碼的專案->屬性->編譯->進階-》將產生序列化組件修改為off(目標framework該不該都ok):