How to convert a Portable Class Library Project (PCL) to a Full .Net Framework Project


Scenario:

You need to convert a PCL library to a full version of the framework. You may run into this scenario if you are running code on a server that you cannot patch and is not fully patched with the latest .Net patches. There is a bug where PCL libraries will not run on .Net Framework 4.0 sites that aren't current in their patching (You will receive an error that goes something like this Could not load file or assembly, 'System, Version=2.0.5.0...').

In an ideal world you would be able to have your hosting service apply KB2468871 (http://www.microsoft.com/en-us/download/details.aspx?id=3556). We don't always live in an ideal world.

How to change your project from a PCL to a full .Net project:

  1. Open your project file, you can do this in Visual Studio (it should unload the project)
  2. Find the TargetFrameworkProfile xml tag and remove it.
  3. Find the ProjectTypeGuids xml tag and remove it.
  4. If you are running C#, change <Import Project="$(MSBuildExtensionsPath32)MicrosoftPortable$(TargetFrameworkVersion)Microsoft.Portable.CSharp.targets" /> to
  5. If you are running Visual Basic, change <Import Project="$(MSBuildExtensionsPath32)MicrosoftPortable$(TargetFrameworkVersion)Microsoft.Portable.VisualBasic.targets" /> to
  6. If you are still in Visual Studio (and not using some kind of Notepad) the right click on the project and reload it. It should now be ready to compile under the full version of the Framework. You can now go into the properties and change the target framework to whatever you would like.

Leave a comment

Please note that we won't show your email to others, or use it for sending unwanted emails. We will only use it to render your Gravatar image and to validate you as a real person.