?
Solved

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

Posted on 2012-09-03
9
Medium Priority
?
4,077 Views
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
0
Comment
Question by:Julian Hansen
  • 4
  • 2
  • 2
  • +1
9 Comments
 
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.

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
 
LVL 60

Author Comment

by:Julian Hansen
ID: 38361082
How do you do that on a hosted server?
0
 
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 :

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

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

Alan
0
 
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">
			<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
 
LVL 26

Accepted Solution

by:
Alan Warren earned 1600 total points
ID: 38366020
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
 
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.
0
 

Expert Comment

by:avanceconsulting
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.
Regards,
Karunaker
0
 
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.
0

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