【问题标题】:Why did reinstalling Silverlight break my Import configuration?为什么重新安装 Silverlight 会破坏我的导入配置?
【发布时间】:2013-06-21 09:16:43
【问题描述】:

根据此处的答案: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)。我什至还安装了用于 Web 的 VS Express (2012)!

更新 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。为什么编译器会编译成功,但是当我去运行应用程序时,却突然停了下来,以一种不自然的尖锐声调尖叫着“编译错误”?

【问题讨论】:

  • 我升级到VS2013后也遇到了同样的问题,但没有找到任何解决方案。我把它贴在stackoverflow.com/questions/20054544/…
  • +100 非常感谢您这篇非常详细的帖子。您的更新 5 在更新 VS 2015 后修复了我的 Silverlight 问题。我希望我能一次又一次地支持这篇文章。向你致敬!
  • @AnneLagang:我很高兴它有帮助!

标签: silverlight versioning importerror csproj


【解决方案1】:

安装“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

【讨论】:

  • 我知道这已经很老了,但我想知道现在是否可以通过 Nuget 包获得相同的内容:nuget.org/packages/Unofficial.SilverlightToolkit-All我不是 .NET 程序员,所以我不知道这是否其实也是SDK。
  • 检查这两个项目是否已安装以及@msgeek 提到的 Microsoft® Silverlight® 5 Tools for Visual Studio 已为我修复。
【解决方案2】:

我有同样的问题,我刚刚修复了我的 Visual Studio 2012 安装(未选中开发工具包 Silverlight),一切都很好

【讨论】:

  • 我选择了Modify 而不是Repair,之后VS 提示我安装Silverlight Developer(也提供了下载链接)。只有这样它才对我有用。
【解决方案3】:

根据您的版本下载并安装 Microsoft® Silverlight® 5 Tools for Visual Studio,这解决了我的问题 VS2010链接-http://www.microsoft.com/en-us/download/details.aspx?id=28358

【讨论】:

猜你喜欢
  • 2018-09-20
  • 1970-01-01
  • 2020-11-14
  • 1970-01-01
  • 2021-12-12
  • 1970-01-01
  • 2012-01-01
  • 2011-02-10
  • 2013-06-25
相关资源
最近更新 更多