I know it has been asked before, but none worked for me and mine is a little bit different.
My MVC 4 project works locally but in server it fails to run with this error:
Compiler Error Message: CS0246: The type or namespace name 'ProfileCommon' could not be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 194: }
Line 195:
Line 196: protected ProfileCommon Profile {
Line 197: get {
Line 198: return ((ProfileCommon)(this.Context.Profile));
Source File: c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\e3c4a897\ff4f4317\App_Web_pageheader.ascx.cdcab7d2.rpk2croq.0.cs Line: 196
I have written a custom ProfileProvider
and configured the project to use it:
<profile enabled="true" defaultProvider="sql">
<providers>
<clear />
<add name="sql" type="BusinessLogic.ProfileProvider" connectionStringName="c" applicationName="/" />
</providers>
</profile>
I use ProfileBase
class to access user profile not ProfileCommon
. The error above is in a compiler generated file. why asp.net generates a code that it can't compile? and why it's working locally?
I have .Net Framework 4.5.1 installed locally but in server it's 4.5 . is it related to the problem?
From a quick read of that it seems like the ProfileCommon gets created when the project is built based on the web.config profile settings. This explains why it works in your app_code folder as this is still apart of the web site where as the class library project is not a website.
Without the correct name, the compiler cannot find the definition for the type or namespace. This often occurs because the casing used in the name of the type is not correct. For example, Dataset ds; generates CS0246 because the s in Dataset must be capitalized. If the error is for a namespace name, did you add a reference to the assembly that
In your class library project you need to add the namespace System.Web.Profile to the class file you want to use he ProfileCommon class. Make sure you have added the System.Web assembly to your project. Go to the references node in your class library project and choose to add a new reference, and in the list add System.Web I have.
The type or namespace name 'type/namespace' could not be found (are you missing a using directive or an assembly reference?) A type or namespace that is used in the program was not found. You might have forgotten to reference (-reference) the assembly that contains the type, or you might not have added the required using directive.
The same thing occurred for me (although with WebForms with WebAPI services) in our deployment when we moved from a Web Site Project to a Web Application Project.
The solution in our case was to delete PrecompiledApp.config out of the deployed folder on the server, and restart IIS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With