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

Posted on 2012-09-03
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
    LVL 16

    Assisted Solution

    by:Vikram Singh Saini
    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 50

    Author Comment

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

    Expert Comment

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

    But I found a link that describe your problem :
    LVL 26

    Expert Comment

    by:Alan Warren
    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 50

    Author Comment

    by:Julian Hansen
    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

    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, 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"/>
            <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 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="" 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 50

    Author Comment

    by:Julian Hansen
    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

    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 50

    Author Comment

    by:Julian Hansen
    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

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    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 …
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    755 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now