ASP.NET Error - ProfileCommon could not be found

While converting a Web site project to a Web App project, you may encounter an error: The type or namespace name 'ProfileCommon' could not be found (are you missing a using directive or an assembly reference?)

It so happens that if you are using the ASP.NET Web site project template, you have Profiles autogenerated for you, out of the box. However Web App projects don't support the auto generation of the ProfileCommon.

What is Profile Common?

ASP.NET uses the ProfileBase class to create the class used for the user profile. When an application that has the user profile enabled is started, ASP.NET creates a new class of type ProfileCommon, which inherits from the ProfileBase class.

A simple fix is to install the Web Profile Builder which is a build task. When you configure this build task in your project file, it creates a wrapper class for the Web Profile and keep it updated every time your project builds. You will then have strongly typed access to the Profile object in Web Application Projects.

The installation is pretty simple : Run the installer and add an Import statement to your project file.

<Import Project="$(MSBuildExtensionsPath)\WebProfileBuilder\WebProfileBuilder.targets" />

That’s it. You are good to go!

Note: For VS 2010 projects, click the ‘Show All Files’ icon in the Solution explorer, right click the webprofile file and include it in the project.


Will you give this article a +1 ? Thanks in advance


About The Author

Suprotim Agarwal
Suprotim Agarwal, Developer Technologies MVP (Microsoft Most Valuable Professional) is the founder and contributor for DevCurry, DotNetCurry and SQLServerCurry. He is the Chief Editor of a Developer Magazine called DNC Magazine. He has also authored two Books - 51 Recipes using jQuery with ASP.NET Controls. and The Absolutely Awesome jQuery CookBook.

Follow him on twitter @suprotimagarwal.

No comments: