silverlight - 为什么重新安装 Silverlight 会破坏我的导入配置?

标签 silverlight versioning importerror csproj

基于此处的答案: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) Web 版!

更新2

根据另一条提示,我还安装了 Silverlight 4 SDK,但现在尝试打开项目时,我得到:“在打开 Silverlight 项目之前,您需要安装最新的 Silverlight Developer 运行时‘布拉’。” 它让我(再次)安装 Silverlight 5。

我这样做了,但我重新启动了,并且...仍然收到相同的错误消息...

更新3

根据我在这里得到的线索: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" />

...我比以前进步了,但我不知道最后的更改是否是必要的更改,或者上面列举的所有步骤是否都是必要的。除了影子之外,很可能没有人知道。

更新4

实际上,只需添加该行(无需替换另一行),项目就会编译,但随后似乎会失去对 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

更新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

...我更进一步,但再次回到这个编译点:

@Helprs.Sitemap(ConfigurationManager.AppSettings["ApplicationHome"])

更新6

关于这一切的一个非常奇怪的事情是,解决方案可以编译,但是当我运行它时,它会抛出一个 YSOD,声称是编译错误的结果。为什么编译器可以成功编译,但是当我运行应用程序时,却突然停止,并以一种不自然的尖锐声调尖叫出“编译错误”?

最佳答案

安装“Microsoft® Silverlight® 5 SDK”和 x64 运行时 为我工作。

SDK https://www.microsoft.com/en-us/download/details.aspx?id=28359

x64 https://www.microsoft.com/en-my/download/details.aspx?id=28358

关于silverlight - 为什么重新安装 Silverlight 会破坏我的导入配置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17282705/

相关文章:

silverlight - 提供的 URI 方案 'file' 预期无效 'http'

c# - 如何从 Windows Phone 8.1 Silverlight 中的列表框中删除所选项目

api - 使用子域对 REST API 进行版本控制

Python 导入没有 "from"

anaconda - conda 导入错误 : No module named conda. cli

c# - 如何在 Silverlight 中获取路径的 X 和 Y 位置?

asp.net - 在 Silverlight/WPF 或 ASP.NET 中开发业务应用程序的相对工作量/生产力?

c - 语义版本控制 : minor or major change?(第二部分)

c# - 如何在我的应用程序中显示上次构建的内部版本号和/或日期时间?

python - pycuda.driver 中的 pycuda ImportError