根据这里的答案:Which, if any, recent Windows updates should I uninstall to revivify Silverlight or rectify other problems?,我卸载/重新安装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" />
我完全不明白这是做什么的;如果这是远方可以理解的东西,我需要做些什么才能解决这个难题?
当我尝试安装Silverlight 4工具时(因为某些指示是/解决方案,例如在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=177432以其他语言提供。 “
我做安装了VS 2010(SP1)。我甚至安装了VS Express(2012)for Web!
基于另一个提示,我还安装了Silverlight 4 SDK,但是现在尝试打开项目时,我得到了“你需要在打开Silverlight项目之前安装最新的Silverlight Developer运行时“布拉”。” 它让我安装了Silverlight 5(再次)。
我这样做了,但我重新启动了,并且......仍然得到同样的错误消息...
我在csproj文件中替换了这一行:
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
......用这个:
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
...而且我比以前更进一步,但我不知道最后一次更改是否是必要的更改,或者上面列举的所有步骤是否都是必要的。除了暗影之外,很可能没有人知道。
实际上,只需添加该行(无需替换另一行),项目编译,但似乎失去了对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
好吧,无论出于什么原因,在地平线上恍然大悟的短暂瞥见只是一个短暂的海市蜃楼 - 同样的错误在发布上一次更新后立即返回。
然而,一旦我更换了这个:
<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
...我走得更远,但又回到了这个编译点:
@Helprs.Sitemap(ConfigurationManager.AppSettings["ApplicationHome"])
关于所有这些的一些非常离奇的是解决方案编译,但是当我运行它时,它会抛出一个声称是编译错误结果的YSOD。为什么编译器会成功编译,但是当我去运行应用程序时,突然停止,以一种不自然的尖锐语气尖叫出“编译错误”?
答案 0 :(得分:9)
安装“Microsoft®Silverlight®5SDK”和x64运行时 为我工作。
SDK https://www.microsoft.com/en-us/download/details.aspx?id=28359
64 https://www.microsoft.com/en-my/download/details.aspx?id=28358
答案 1 :(得分:5)
我有同样的问题,我只是修复了我的Visual Studio 2012安装(开发工具包Silverlight未经检查)之后,一切都很好
答案 2 :(得分:2)
根据您的版本下载并安装适用于Visual Studio的Microsoft®Silverlight®5工具,解决了我的问题 VS2010链接 - http://www.microsoft.com/en-us/download/details.aspx?id=28358