Reputation: 1027
Gooday, I'm creating an ASP.NET with C# Website in Visual Studio. I used ProfileCommon and stumbled upon this error:
The type or namespace name 'ProfileCommon' could not be found (are you missing a using directive or an assembly reference?)
Hope it has a quick fix? What directive should I include? Thanks a lot.
EDIT: Any advice? - After I installed this add-in: http://archive.msdn.microsoft.com/WebProfileBuilder/Release/ProjectReleases.aspx?ReleaseId=980
Error 1 The "BuildWebProfile" task failed unexpectedly. System.ArgumentNullException: String reference not set to an instance of a String. Parameter name: s at System.Text.Encoding.GetBytes(String s) at WebProfileBuilder.Builder.IsProfileSame() at WebProfileBuilder.Builder.GenerateWebProfile(BuildWebProfile buildWebProfile) at WebProfileBuilder.BuildWebProfile.Execute()
at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult) Cinemax
Upvotes: 4
Views: 10058
Reputation: 188
I ran into a similar issue with ProfileCommon not being found and my ASP.NET Web Site not building with the very unhelpful error:
The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception.
I was able to fix it by correcting the capitalization of the sessionState mode in my Web.config file to:
<sessionState mode="Off"/>
Upvotes: 0
Reputation: 259
I spent a lot of time to understand the issue. For me, WebApplication project works fine localy but I got this error on deployed version of WebApplication. WebApplication does not create ProfileCommon class automatically. Therefore, I create following class in project (without namespace that all generated code will see it):
public class ProfileCommon: ProfileBase
{
}
That`s it!
But if you use Profile property of page for getting and updating current user profile, you can inherit from your profile class instead of ProfileBase
Upvotes: 0
Reputation: 1949
In my case i had to add the profile Element to the web.config file.
<profile enabled="true" defaultProvider="MyCustomProfileProvider">
...
</profile>
see MSDN -profile Element (ASP.NET Settings Schema)
Upvotes: 0
Reputation: 1752
Look here: http://forums.asp.net/t/1031740.aspx/1 or here Error "The type or namespace name 'ProfileCommon' could not be found"
The base class for the profiles is ProfileBase class which is used to handle the user profiles. When the web application has the user profile as enabled, a new class gets created called ProfileCommon. This class is used for the accessors for each property which is defined in the profile configuration section. The accessors of ProfileCommon class then calls the getter and setter to retrieve and set the property values.
You need to add using System.Configuration;
and System.Web.Profile;
to your project.
You might get further information here: http://msdn.microsoft.com/en-us/library/system.web.profile.profilebase.aspx
Hope that helps !
Upvotes: 1
Reputation: 15253
Very likely you're using the Web Application project template. Profiles only come out of the box with the website project template. For a solution, see here and here.
Upvotes: 1