Why did reinstalling Silverlight break my Import configuration?

B. Clay Shannon picture B. Clay Shannon · Jun 24, 2013 · Viewed 8.2k times · Source

Based on the answer here: Which, if any, recent Windows updates should I uninstall to revivify Silverlight or rectify other problems?, I uninstalled / reinstalled Silverlight and rebooted. Now, though, I get a compilation error, namely:

"The imported project "C:\Program Files (x86)\MSBuild\Microsoft\Silverlight\v5.0\Microsoft.Silverlight.CSharp.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk."

It points to this line in a *.csproj file:

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />

I don't understand what this is doing, exactly; if it's something grokkable from afar, what do I need to do to solve this dilemma?

UPDATE

When I try to install the Silverlight 4 Tools (as some indicate is a/the solution, such as at Silverlight 4: Resolving Microsoft.Silverlight.CSharp.targets was not found?), I get, "Installation Requirements:

Visual Studio 2010 or Visual Web Developer Express 2010 or Visual Phone Developer Express 2010 that matches the language version of Silverlight Tools 4 must be installed before installation of Silverlight Tools can continue. Silverlight Tools is available in other languages at http://go.microsoft.com/fwlink/?LinkId=177432. "

I do have VS 2010 (SP1) installed. And I even have VS Express (2012) for Web installed, too!

UPDATE 2

Based on another tip, I also installed the Silverlight 4 SDK, but on trying to just open the project now, I get, "You need to install the latest Silverlight Developer runtime before opening Silverlight project 'Bla'." It had me install Silverlight 5 (again).

I did so, but I rebooted, and...still get that same err msg...

UPDATE 3

Based on a clue I got here: http://connect.microsoft.com/VisualStudio/feedback/details/573750/the-imported-project-path-microsoft-webapplication-targets-was-not-found

I replaced this line in the csproj file:

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />

...with this one:

<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

...and I get further along than before, but I don't know if that last change was the necessary alteration, or if all of the steps enumerated above are necessary. Other than the Shadow, it's likely that nobody knows.

UPDATE 4

Actually, simply adding that line (no need to replace the other), the project compiles, but then seems to lose its knowledge of Razor or something, as it fails with this 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

Okay, for whatever reason that brief glimpse of hope that dawned on the horizon was just a fleeting mirage - the same err returned immediately after having posted the previous update.

However, once I replaced this:

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />

...with this:

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\v4.0\Microsoft.Silverlight.CSharp.targets" />

...based on this: http://msdn.microsoft.com/en-us/library/ff921165(v=PandP.20).aspx

...I get further, but again just back to this compilation point:

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

UPDATE 6

Something quite bizarre about all of this is that the solution compiles, but when I run it, it throws up a YSOD that claims to be the results of a compilation error. Why would the compiler successfully compile, but then when I go to run the app, come to a screeching halt, squealing out "Compilation Error" in an unnaturally shrill tone?

Answer

pawciu picture pawciu · Dec 14, 2015

Installing "Microsoft® Silverlight® 5 SDK" and x64 runtime worked for me.

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

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