If you’ve worked with .NET 4, you might have run into this before. You’re casually typing and clicking along and then you go to add a reference to your project; but suddenly your application won’t build any more. The error complains about your targeted framework and a Microsoft library dependency. This library is included in .NET, but it won’t add to my project! What gives?
The referenced assembly "StructureMap" could not be resolved because it has a dependency on "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project.
The Problem
If you take a closer look at the error, you’ll notice the targeted framework includes the text Profile=Client.
The .NET Framework 4 Client Profile is a subset of the .NET Framework 4 that is optimized for client applications; it restricts the set of referenced assemblies to only those that are interesting to a client application. For example, it won’t make System.Web available by default because it is not typically valuable to client apps.
So if you started building a Forms app (or WCF or WPF), Visual Studio might have defaulted you to target the .NET Framework 4 Client Profile instead of just .NET Framework 4. And now, it’s complaining because you want to add libraries that a client application doesn’t typically have any use for.
The Solution
Right-click the project that needs the reference added, click properties, and update the project to target .NET Framework 4 instead of the Client Profile.
Now get back to work!