基于这里的答案:我应该卸载哪些最新的 Windows 更新(如果有)来恢复 Silverlight 或纠正其他问题? https://stackoverflow.com/questions/17242578/which-if-any-recent-windows-updates-should-i-uninstall-to-revivify-silverlight,我卸载/重新安装了 Silverlight 并重新启动。但现在,我收到一个编译错误,即:
“找不到导入的项目“C:\Program Files (x86)\MSBuild\Microsoft\Silverlight\v5.0\Microsoft.Silverlight.CSharp.targets”。请确认声明中的路径正确,并且该文件存在于磁盘上。”
它指向 *.csproj 文件中的这一行:
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
我不明白这到底在做什么;如果这是从远处可以理解的事情,我需要做什么来解决这个困境?
UPDATE
当我尝试安装 Silverlight 4 工具时(正如某些人指出的那样,解决方案,例如在Silverlight 4:未找到解析 Microsoft.Silverlight.CSharp.targets? https://stackoverflow.com/questions/3591369/silverlight-4-resolving-microsoft-silverlight-csharp-targets-was-not-found),我得到,“安装要求:
必须先安装与 Silverlight Tools 4 语言版本匹配的 Visual Studio 2010 或 Visual Web Developer Express 2010 或 Visual Phone Developer Express 2010,然后才能继续安装 Silverlight Tools。 Silverlight 工具的其他语言版本如下: http://go.microsoft.com/fwlink/?LinkId=177432http://go.microsoft.com/fwlink/?LinkId=177432 http://go.microsoft.com/fwlink/?LinkId=177432. "
I do安装了 VS 2010 (SP1)。我什至还安装了 VS Express (2012) Web 版!
UPDATE 2
根据另一个提示,我还安装了 Silverlight 4 SDK,但试图只是open现在,我得到该项目,“您需要在打开 Silverlight 项目‘Bla’之前安装最新的 Silverlight Developer 运行时。”
它让我(再次)安装 Silverlight 5。
我这样做了,但我重新启动了,并且......仍然得到相同的错误消息......
UPDATE 3
根据我在这里得到的线索:http://connect.microsoft.com/VisualStudio/feedback/details/573750/the-imported-project-path-microsoft-webapplication-targets-was-not-found http://connect.microsoft.com/VisualStudio/feedback/details/573750/the-imported-project-path-microsoft-webapplication-targets-was-not-found
我替换了 csproj 文件中的这一行:
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
...用这个:
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
...我比以前进步了,但我不知道最后的更改是否是必要的更改,或者上面列举的所有步骤是否都是必要的。除了影子之外,可能没有人知道。
UPDATE 4
其实简单来说adding该行(无需替换其他行),项目compiles,但随后似乎失去了 Razor 或其他东西的知识,因为它因以下 YSOD 失败:
Server Error in '/TLDReporter' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'Helprs' does not exist in the current context
Source Error:
Line 493: <div class="inner" style="width: 300px;">
Line 494: <p id="portal_breadcrumbs" class="breadcrumb">
Line 495: @Helprs.Sitemap(ConfigurationManager.AppSettings["ApplicationHome"])
Line 496: </p>
Line 497: </div>
Source File: c:\Project\. . .\Shared\_Layout.cshtml Line: 495
UPDATE 5
好吧,无论出于何种原因,地平线上出现的短暂希望只是转瞬即逝的海市蜃楼——在发布上一个更新后,同样的错误立即返回。
然而,一旦我更换了这个:
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
...有了这个:
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\v4.0\Microsoft.Silverlight.CSharp.targets" />
...基于此:http://msdn.microsoft.com/en-us/library/ff921165(v=PandP.20).aspx http://msdn.microsoft.com/en-us/library/ff921165(v=PandP.20).aspx
...我更进一步,但再次回到这个编译点:
@Helprs.Sitemap(ConfigurationManager.AppSettings["ApplicationHome"])
UPDATE 6
所有这一切都非常奇怪的是,解决方案可以编译,但是当我运行它时,它会抛出一个 YSOD,声称是编译错误的结果。为什么编译器会成功编译,但当我运行应用程序时,却突然停止,以一种不自然的尖锐声调尖叫出“编译错误”?