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

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
LVL 63
Julian HansenAsked:
Who is Participating?
 
Alan WarrenConnect With a Mentor Applications DeveloperCommented:
Hi julianH,

Re:
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)
   {
		try
		{

			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();
			Profile.Save();

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"?>
<configuration>
  <appSettings>
    <add key="ChartImageHandler" value="Storage=file;Timeout=20;Url=~/tempimages/;"/>
  </appSettings>
  <connectionStrings>
     <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"/>
  </connectionStrings>
  <system.web>
    <!-- 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">
      <assemblies>
        <add assembly="AjaxControlToolkit, Version=4.1.60623, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
        <add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="Office, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"/>
      </assemblies>
    </compilation>
    <roleManager enabled="true" defaultProvider="SqlRoleManager">
      <providers>
        <add name="SqlRoleManager" type="System.Web.Security.SqlRoleProvider" connectionStringName="cn" applicationName="AppName"/>
      </providers>
    </roleManager>
    <authorization>
      <!--
      The <authentication> section enables configuration 
      of the security authentication mode used by 
      ASP.NET to identify an incoming user. 
      -->
      <allow users="*"/>
    </authorization>
    <profile enabled="true" defaultProvider="CustomizedProvider">
      <!-- Custom profile properties -->
      <providers>
        <remove name="CustomizedProvider"/>
        <add name="CustomizedProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="cn" applicationName="AppName" description="SqlProfileProvider for AppName.com"/>
      </providers>
      <properties>
        <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"/>
      </properties>
    </profile>
    <anonymousIdentification enabled="true" cookieName=".ASPXANONYMOUS" cookieTimeout="43200" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All" cookieless="UseCookies"/>
    <authentication mode="Forms">
      <forms timeout="10"/>
    </authentication>
    <pages enableViewState="true" enableViewStateMac="true" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
      <namespaces>
        <clear/>
        <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"/>
      </namespaces>
      <controls>
        <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </controls>
    </pages>
    <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-->
      <providers>
        <clear/>
        <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"/>
      </providers>
    </membership>
    <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">
      <providers>
        <add name="XmlSiteMapProvider" description="Default SiteMap provider for anonymous users." type="System.Web.XmlSiteMapProvider " siteMapFile="~/web.sitemap" securityTrimmingEnabled="true"/>
      </providers>
    </siteMap>
    <!-- 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"/>
    <httpHandlers>
      <add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
    </httpHandlers>
    <caching>
      <outputCacheSettings>
        <outputCacheProfiles>
          <!-- 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"/>
        </outputCacheProfiles>
      </outputCacheSettings>
      <sqlCacheDependency enabled="true" pollTime="60000">
        <databases>
          <add name="somecat" connectionStringName="cn" pollTime="60000"/>
        </databases>
      </sqlCacheDependency>
    </caching>
  </system.web>
  <system.net>
    <mailSettings>
      <smtp>
        <network host="SMTP.GMAIL.COM" password="somepwd" port="587" userName="someuser@AppName.com" defaultCredentials="false"/>
      </smtp>
    </mailSettings>

  </system.net>
  <system.webServer>
    <!-- 
    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"/>
    <handlers>
      <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=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </handlers>
  </system.webServer>
  <system.web.extensions>
    <scripting>
      <scriptResourceHandler enableCompression="false" enableCaching="true"/>
    </scripting>
  </system.web.extensions>
</configuration>

Open in new window

Alan ";0)
0
 
Vikram Singh SainiConnect With a Mentor Software Engineer cum AD DeveloperCommented:
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.

Reason:
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.

Solution
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.
0
 
Julian HansenAuthor Commented:
How do you do that on a hosted server?
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Vikram Singh SainiSoftware Engineer cum AD DeveloperCommented:
I think that would not be possible on hosted server.

But I found a link that describe your problem :

http://gregorybeamer.wordpress.com/2008/09/26/solving-the-profilecommon-ambiguous-error/
0
 
Alan WarrenApplications DeveloperCommented:
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.

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

Alan
0
 
Julian HansenAuthor Commented:
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">
			<providers>
				<clear/>
				<add name="AspNetSqlMembershipProvider"
					 type="System.Web.Security.SqlMembershipProvider"
					 connectionStringName="connect"
					 enablePasswordRetrieval="true"
					 minRequiredPasswordLength="5"
					 minRequiredNonalphanumericCharacters="0"
					 requiresQuestionAndAnswer="False"
					 passwordFormat="Clear"
					 applicationName="UniqueApplicationNameChangedForEEPost" />
			</providers>
		</membership>
		<profile defaultProvider="MyCustomProfileProvider">
			<providers>
				<clear/>
				<add name="MyCustomProfileProvider"
					 connectionStringName="connect"
					 type="Microsoft.SqlTableProfileProvider"
					 table="Member"
					 profileVersion="1"
					 applicationName="UniqueApplicationNameChangedForEEPost" />
			</providers>
			<properties>
				<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" />
			</properties>
		</profile>

Open in new window

0
 
Julian HansenAuthor Commented:
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.
0
 
avanceconsultingCommented:
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.
Regards,
Karunaker
0
 
Julian HansenAuthor Commented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.