Compilation Error: The type 'ProfileCommon' exists in both ... ???

Posted on 2012-09-03
Medium Priority
Last Modified: 2012-12-26
We have a site that has been up and running for a while. Out of nowhere this error started appearing when trying to access the site.

CS0433: The type 'ProfileCommon' exists in both 'c:\windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\cf2b8434\95f525a3\App_Code.0i70ivrk.dll' and 'c:\windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\cf2b8434\95f525a3\assembly\dl3\ec82ca57\4c212851_fe6ecd01\App_Code.DLL'

Has anyone had any experience with this
Question by:Julian Hansen
  • 4
  • 2
  • 2
  • +1
LVL 16

Assisted Solution

by:Vikram Singh Saini
Vikram Singh Saini earned 400 total points
ID: 38360985
Yes! I have had experience with this.

Cause behind this:
Suppose you are having two web applications hosted on IIS server. And both of these applications are using same type of custom .cs files in App_Code folder. So sometime while handling request for these websites, this error message gets displayed.

It's my assumption that the IIS expects the .dll(s) files to be of unique and strong named one. It could be reason from .Net context for security purpose so that no two assemblies request gets conflicted.

Unable to find a reasonable solution. Except that deleting these two different types of temporary files from the c:\windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files.
LVL 60

Author Comment

by:Julian Hansen
ID: 38361082
How do you do that on a hosted server?
LVL 16

Expert Comment

by:Vikram Singh Saini
ID: 38361143
I think that would not be possible on hosted server.

But I found a link that describe your problem :

Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

LVL 26

Expert Comment

by:Alan Warren
ID: 38363444
Just a hunch; I'd be inclined to suspect an applicationName conflict in the web.config.
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="mycn" applicationName="/" />

Most people deploy their apps using the "/" as the application name, which leaves it up to IIS to figure it out.

<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="mycn" applicationName="/mywebsite" />

LVL 60

Author Comment

by:Julian Hansen
ID: 38363704
Thanks Alan,

The application name was set to the application name i.e. not '/'. As an added test I changed it to something else - same problem.

The error points to this bit of code
Line 125:          protected ProfileCommon Profile {
Line 126:              get {
Line 127:                  return ((ProfileCommon)(this.Context.Profile));
Line 128:              }
Line 129:          }

Open in new window

The web config does define a custom profile provider like so - I did read somewhere that something in this could be the problem - but not sure how to proceed ....
		<membership defaultProvider="AspNetSqlMembershipProvider">
				<add name="AspNetSqlMembershipProvider"
					 applicationName="UniqueApplicationNameChangedForEEPost" />
		<profile defaultProvider="MyCustomProfileProvider">
				<add name="MyCustomProfileProvider"
					 applicationName="UniqueApplicationNameChangedForEEPost" />
				<add name="MemberId" type="int" defaultValue=" " customProviderData="MemberId;int" />
				<add name="MembershipTypeId" type="int" defaultValue=" " customProviderData="MembershipTypeId;int" />
				<add name="CountryId" type="int" defaultValue="" customProviderData="CountryId;int" />
				<add name="StateId" type="int" defaultValue="" customProviderData="StateId;int" />
				<add name="GenderId" type="int" defaultValue="" customProviderData="GenderId;int" />
				<add name="PaymentSubscriptionId" type="int" defaultValue="0" customProviderData="PaymentSubscriptionId;int" />
				<add name="Firstname" type="string" defaultValue=" " customProviderData="Firstname;nvarchar" />
				<add name="Surname" type="string" defaultValue=" " customProviderData="Surname;nvarchar" />
				<add name="EmailAddress" type="string" defaultValue=" " customProviderData="EmailAddress;nvarchar" />
				<add name="DateOfBirth" type="datetime" defaultValue=" " customProviderData="DateOfBirth;datetime" />
				<add name="ProfileImageLocation" type="string" defaultValue=" " customProviderData="ProfileImageLocation;nvarchar" />
				<add name="ZipCode" type="string" defaultValue=" " customProviderData="ZipCode;nvarchar" />
				<add name="LastUpdatedDate" type="datetime" defaultValue="[getdate()]" customProviderData="LastUpdatedDate;datetime" />
				<add name="CreatedDate" type="datetime" defaultValue="[getdate()]" customProviderData="CreatedDate;datetime" />
				<add name="IsActive" type="bool" defaultValue="[1]" customProviderData="IsActive;bit" />

Open in new window

LVL 26

Accepted Solution

Alan Warren earned 1600 total points
ID: 38366020
Hi julianH,

Line 125:          protected ProfileCommon Profile {
Line 126:              get {
Line 127:                  return ((ProfileCommon)(this.Context.Profile));
Line 128:              }
Line 129:          }

Open in new window

Is this in your code or the asp_net temporary files folder, maybe something like : C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\appname\134685ae\4ebf521d\App_Web_ovwcxmjm.8.vb

If in your code, the protected readonly property already exists.
When I define the same on my machine it returns the error: Protected ReadOnly Property Profile As ProfileCommon' has multiple definitions with identical signatures.

As far as I am aware Profile (the vanilla version thereof) returns ProfileCommon, which is the current context user profile.

so you could simply address Profile (the vanilla version) like:
   protected void btnSave_Click(object sender, System.EventArgs e)

			string strErrMsg = "";

			Profile.BirthDate = Convert.ToDateTime(m_strDOB);
			Profile.Country = Country.SelectedIndex;
			Profile.CountryName = Country.SelectedItem.Text.ToString();
			Profile.Gender = Gender.SelectedItem.Text.ToString();
			Profile.Bio = Bio.Text.ToString();
			Profile.Interests = Interests.Text.ToString();
			Profile.Hobbies = InterestsOther.Text.ToString();
			Profile.Education = Education.Text.ToString();

Open in new window

The script above is populating some custom profile properties, which can be set up in the web.config, here's a copy of my web.config, minus a few sensitives, for comparison:
<?xml version="1.0"?>
    <add key="ChartImageHandler" value="Storage=file;Timeout=20;Url=~/tempimages/;"/>
     <remove name="cn"/>
    <add name="cn" connectionString="Data Source=alzowze;Initial Catalog=somecat;Connect Timeout=15; pooling='true'; Max Pool Size=200;Persist Security Info=True;User ID=someuser;Password=somepwd" providerName="System.Data.SqlClient"/>
    <!-- By default, asp.net outputs html that is xhtml transitional compliant. 
         You can adjust this by changing a setting in the web.config. -->
    <xhtmlConformance mode="Strict"/>
    <customErrors mode="Off"/>
    <!-- Switch for deployment debug="false" -->
    <compilation debug="true" strict="false" explicit="true" defaultLanguage="vb" targetFramework="4.0">
        <add assembly="AjaxControlToolkit, Version=4.1.60623, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
        <add assembly="System.Web.DataVisualization, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="Office, Version=, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"/>
    <roleManager enabled="true" defaultProvider="SqlRoleManager">
        <add name="SqlRoleManager" type="System.Web.Security.SqlRoleProvider" connectionStringName="cn" applicationName="AppName"/>
      The <authentication> section enables configuration 
      of the security authentication mode used by 
      ASP.NET to identify an incoming user. 
      <allow users="*"/>
    <profile enabled="true" defaultProvider="CustomizedProvider">
      <!-- Custom profile properties -->
        <remove name="CustomizedProvider"/>
        <add name="CustomizedProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="cn" applicationName="AppName" description="SqlProfileProvider for AppName.com"/>
        <add name="Country" type="Int32" allowAnonymous="true"/>
        <add name="CountryName" type="String" allowAnonymous="true"/>
        <add name="BirthDate" type="System.DateTime" allowAnonymous="true"/>
        <add name="Gender" type="String" allowAnonymous="true"/>
        <add name="ValidEmail" type="System.Boolean" allowAnonymous="true" defaultValue="false"/>
        <add name="Bio" type="System.String" allowAnonymous="true"/>
        <add name="Interests" type="System.String" allowAnonymous="true"/>
        <add name="Hobbies" type="System.String" allowAnonymous="true"/>
        <add name="Education" type="System.String" allowAnonymous="true"/>
        <add name="ProfileImages" type="System.Collections.Specialized.StringCollection" allowAnonymous="true"/>
        <add name="PrimaryImage" type="System.Collections.Specialized.StringCollection" allowAnonymous="true"/>
    <anonymousIdentification enabled="true" cookieName=".ASPXANONYMOUS" cookieTimeout="43200" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All" cookieless="UseCookies"/>
    <authentication mode="Forms">
      <forms timeout="10"/>
    <pages enableViewState="true" enableViewStateMac="true" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
        <add namespace="System"/>
        <add namespace="System.Collections"/>
        <add namespace="System.Collections.Specialized"/>
        <add namespace="System.Configuration"/>
        <add namespace="System.Text"/>
        <add namespace="System.Text.RegularExpressions"/>
        <add namespace="System.Web"/>
        <add namespace="System.Web.Caching"/>
        <add namespace="System.Web.SessionState"/>
        <add namespace="System.Web.Security"/>
        <add namespace="System.Web.Profile"/>
        <add namespace="System.Web.UI"/>
        <add namespace="System.Web.UI.WebControls"/>
        <add namespace="System.Web.UI.WebControls.WebParts"/>
        <add namespace="System.Web.UI.HtmlControls"/>
        <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    <membership defaultProvider="CustomizedProvider" userIsOnlineTimeWindow="20">
         You should ALWAYS customize the Membership provider and specify an applicationName... 
         see http://weblogs.asp.net/scottgu/archive/2006/04/22/Always-set-the-_2200_applicationName_2200_-property-when-configuring-ASP.NET-2.0-Membership-and-other-Providers.aspx for more details... -->
      <!-- passwordFormat="Hashed" note hashed passwords cannot be retrieved-->
        <add connectionStringName="cn" enablePasswordRetrieval="true" passwordFormat="Encrypted" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" maxInvalidPasswordAttempts="32000" passwordAttemptWindow="10" minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="1" passwordStrengthRegularExpression="" applicationName="AppName" name="CustomizedProvider" type="System.Web.Security.SqlMembershipProvider"/>
    <trace enabled="true" requestLimit="15" pageOutput="false" traceMode="SortByTime" localOnly="true"/>
    <globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-us" uiCulture="en"/>
    <httpRuntime maxRequestLength="1048576" executionTimeout="300" requestValidationMode="2.0"/>
    <siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
        <add name="XmlSiteMapProvider" description="Default SiteMap provider for anonymous users." type="System.Web.XmlSiteMapProvider " siteMapFile="~/web.sitemap" securityTrimmingEnabled="true"/>
    <!-- This needs to be set to 'InProc' if you want the on_Session_End event in global.asax to fire -->
    <sessionState mode="InProc" cookieless="false" timeout="10"/>
    <machineKey validationKey="6F5AEA06CC12196F236A7B18E1B917D3D72DBE0878431252CC9EED92CA3A269CFD3700A6DBD8592B658F7F064E9D45D6740C17009EE28369FFF002A0D680171D" decryptionKey="3470661D541D1C26AF83590F12450065E3952C8CF627913F" validation="SHA1"/>
      <add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
          <!-- Caching for deployment in seconds
                 60 = 1 Minute, 3600 = 1 Hour, 86400 = 1 Day, 604800 = 1 week, -->
          <!-- Caching for local dev -->
          <add name="HomePage" duration="180" varyByParam="none"/>
          <add name="ResourcesPage" duration="180" varyByParam="none"/>
          <add name="MissionPage" duration="604800" varyByParam="none"/>
          <add name="PrivacyPolicy" duration="604800" varyByParam="none"/>
          <add name="ServicesDefault" duration="604800" varyByParam="none"/>
          <add name="HelpDefault" duration="604800" varyByParam="none"/>
          <add name="HelpFrequentlyAskedQuestions" duration="604800" varyByParam="none"/>
      <sqlCacheDependency enabled="true" pollTime="60000">
          <add name="somecat" connectionStringName="cn" pollTime="60000"/>
        <network host="SMTP.GMAIL.COM" password="somepwd" port="587" userName="someuser@AppName.com" defaultCredentials="false"/>

    The system.webServer section is required for running ASP.NET AJAX under Internet
    Information Services 7.0.  It is not necessary for previous version of IIS.
    <validation validateIntegratedModeConfiguration="false"/>
      <remove name="ChartImageHandler"/>
      <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <scriptResourceHandler enableCompression="false" enableCaching="true"/>

Open in new window

Alan ";0)
LVL 60

Author Comment

by:Julian Hansen
ID: 38395031
Apologies for not following up guys.

Have not solved the problem - having to work on it part time.

I suspect the answer is in one of the posts above so going to assign points now and post back when problem is solved.

Expert Comment

ID: 38712788
WOW we've solved this..

For me the issue was because I was deleting the PrecompiledApp.config file
when I deployed the app. Apparently that file tells the .Net runtime that
the app is already compiled and not to recompile it again. Without the file
the runtime tries to compile the app again conflicts arise.

Once I put the file back in and redeployed everything worked fine.
LVL 60

Author Comment

by:Julian Hansen
ID: 38722874
Thanks Karunaker - will give this a try as soon as we are back in the office. For now we are running off the uncompiled source which is working but not ideal.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month13 days, 14 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question