Symptoms
When attempting to compile a .NET application, using Visual Studio 2010, the build fails, and the following warnings, or similar warnings, are issued:The primary reference "System.Configuration.Install", which is a framework assembly, could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "System.Configuration.Install" or retarget your application to a framework version which contains "System.Configuration.Install".
The primary reference "System.ServiceProcess", which is a framework assembly, could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "System.ServiceProcess" or retarget your application to a framework version which contains "System.ServiceProcess".I found that even though the .NET Client profiles are supposed to be a subset of the full profile, many assemblies, including the two noted above, are not included in the "Add Reference" dialog. These assemblies properly appear in the Client Profile. It's as if the list has somehow been modified. Now, to identify the culprit...
Cause
I was building a Windows service project, when the problem first occurred. I ran PEX, to generate additional, parameterized tests, and the gates of programmer hell were flung open. It appears that, PEX "fixed" something in Visual Studio 2010.This issue is now plaguing other projects, as well. All of these projects include one or both of the Install and ServiceProcess assemblies. I already built unit tests via Test-Driven Design (TDD), including Moles detours, and everything worked fine. The service project was set to .NET 4.0 Client Profile, and the test project is required to be set to the full 4.0 profile.
How to Fix the Problem*
In the Properties window pictured here, warning icons appear next to the System.Configuration.Install and System.ServiceProcess assemblies. Also note the version number shows 0.0.0.0. Ah-hah, a clue! The Visual Studio project is unable to determine the framework version for the assembly.To correct the problem, the project file must be edited:
- Unload the broken project
- Right-click the project item, in the Solution Explorer window
- Select Unload Project in the context menu
- Edit the project file
- Right-click the project item, in the Solution Explorer window
- Select Edit
.csproj in the context menu - Locate the broken reference(s):
<Reference Include="System.Configuration.Install" />
- Add a SpecificVersion child node:
<Reference Include="System.Configuration.Install"> <SpecificVersion>True</SpecificVersion> </Reference>
- Save the edited project file
- Close the edited project file
- Reload the project
- Right-click the project file
- Select Reload Project in the context menu
*IMPORTANT NOTE:
This will not correct the problem with dynamically generated project files (*.csproj, *vbproj), such as those generated by the Microsoft Pex and Moles frameworks.
Just for the record, i have exactly the same problem. I'm going to reinstall VS.
ReplyDeleteI tried re-installing VS 2010, to no avail. Please let me know if this corrects the issue!
ReplyDelete