Compile Error CS0433 on pre-compiled ASP.NET 2.0 site

杀马特。学长 韩版系。学妹 提交于 2019-12-21 09:34:14

问题


I keep getting this error ever so often when I launch the debugger to debug my site. I'm using the Telerik controls, and usually the error is in my tab strip. Here is an example of the error I'm looking at right now:

Compiler Error Message: CS0433: The type 'ASP.controls_motorvehiclegeneral_ascx' exists in both 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticsweb\30c716d3\eebad209\App_Web_6wlqh1iy.dll' and 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticsweb\30c716d3\eebad209\App_Web_ro_sgchs.dll'

Source Error:

Line 48:     </telerik:RadTabStrip>
Line 49:     <telerik:RadMultiPage ID="RadMultiPageControls" Runat="server" SelectedIndex="0">
Line 50:     <telerik:RadPageView ID="PageGeneral" runat="server"><uc1:General ID="GeneralControl" runat="server" /></telerik:RadPageView>
Line 51:     <telerik:RadPageView ID="PageVehicle" runat="server"><uc1:VehicleList ID="VehicleList" runat="server" /></telerik:RadPageView>
Line 52:     <telerik:RadPageView ID="PagePerson" runat="server"><uc1:PersonList ID="PersonList" runat="server" /></telerik:RadPageView>

The thing that bothers me most, is if I just keep hitting F5, the page WILL refresh and work as it should. Sometimes it takes several refreshes to do this, others it happens pretty quick. I have not been able to find a solution on the net, as most of the people with this error are upgrading from VS2005 to Web Application, and thus the fix seems to be "Remove your app_code directory, and change the CodeFile= to CodeBehind=. But, the CodeBehind is old, and not used anymore.

In this instance, I'm getting the error on my General tab, but it can happen of ANY of my user controls when it DOES happen.

Has anyone else seen this with pre-compiled pages? I'm using VS2008 SP1.

The other effect I've seen related to this is when I have a GridView setup with a datasource, and the datasource changes, but the page does not update until several other operations, then all at once all the data is filled in... This makes me think there is some sort of cache issue, or compile-time, time-out or something...

I am using a site.master page, and have checked the @Page and @Master directives... Just for the sake of argument, here are the compiler options it's using...

C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE> "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe" /t:library /utf8output /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticsweb\30c716d3\eebad209\assembly\dl3\6614ff9a\005164fc_423cc801\PetersDatePackage.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.IdentityModel\3.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.Common\9.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.Common.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticsweb\30c716d3\eebad209\App_Web_0-em44qa.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticsweb\30c716d3\eebad209\App_Web_6wlqh1iy.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticsweb\30c716d3\eebad209\App_Web_ro_sgchs.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\Microsoft.Build.Utilities\2.0.0.0__b03f5f7f11d50a3a\Microsoft.Build.Utilities.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.ServiceModel\3.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticsweb\30c716d3\eebad209\assembly\dl3\6fe979bb\0056bc44_4b94c701\Microsoft.Practices.EnterpriseLibrary.Common.DLL" /R:"C:\WINDOWS\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticsweb\30c716d3\eebad209\assembly\dl3\ad70f8ed\0010f920_4b94c701\Microsoft.Practices.EnterpriseLibrary.Data.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.ServiceModel.Web\3.5.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticsweb\30c716d3\eebad209\assembly\dl3\d61e8194\009ae0bd_854ec901\Telerik.Web.UI.DLL" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticsweb\30c716d3\eebad209\assembly\dl3\98ba2ae7\211fb135_e674c901\CoreAPI.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\1.0.61025.0__31bf3856ad364e35\System.Web.Extensions.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Management\2.0.0.0__b03f5f7f11d50a3a\System.Management.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticsweb\30c716d3\eebad209\assembly\dl3\62fa267e\9888875e_bb5cc901\AjaxControlToolkit.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\Microsoft.Build.Framework\2.0.0.0__b03f5f7f11d50a3a\Microsoft.Build.Framework.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticsweb\30c716d3\eebad209\App_Code.nufffrfb.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticsweb\30c716d3\eebad209\assembly\dl3\52f6447d\f90fd1c8_b475c901\StatisticsAPI.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticsweb\30c716d3\eebad209\assembly\dl3\955f38e7\982cdc0f_bc5cc901\Validators.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\9.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Runtime.Serialization\3.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticsweb\30c716d3\eebad209\App_Web_nv7t8gs_.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Design\2.0.0.0__b03f5f7f11d50a3a\System.Design.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.WorkflowServices\3.5.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Mobile\2.0.0.0__b03f5f7f11d50a3a\System.Web.Mobile.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticsweb\30c716d3\eebad209\assembly\dl3\a5daf5e0\0071b5e7_909cc701\Microsoft.Practices.ObjectBuilder.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.ProcessingObjectModel\9.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.ProcessingObjectModel.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticsweb\30c716d3\eebad209\App_Web_atcckswk.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll" /out:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticsweb\30c716d3\eebad209\App_Web_zva2jsmk.dll" /D:DEBUG /debug+ /optimize- /win32res:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticsweb\30c716d3\eebad209\zva2jsmk.res" /nowarn:1659;1699;1701 /d:DBCONVERTPUBLIC;CRYSTALSUPPORT  "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticsweb\30c716d3\eebad209\App_Web_zva2jsmk.0.cs" "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticsweb\30c716d3\eebad209\App_Web_zva2jsmk.1.cs" "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticsweb\30c716d3\eebad209\App_Web_zva2jsmk.2.cs"

Anyone have any ideas where I can even start to look?


回答1:


killing Cassini instances as above didn't work for me. ScottGu posted about this issue

setting the batch="false" attribute on the compilation section in web.config worked for me.

<configuration>

   <system.web>
       <compilation debug="false" batch="false"></compilation>
   </system.web>

</configuration>

This tells ASP.NET to dynamically compile individual .aspx/.ascx files into separate assemblies. This avoids the circular reference issue that triggers the exception.




回答2:


For me, closing the IDE, shutting the web site (IIS or Cassini), deleting all of my temporary asp.net files, launching the IDE and doing a full compile does the trick.




回答3:


in IIS you need to restart it by opening the command prompt and typing iisreset then hit enter, however if your using the build in Visual Studio web server (Cassini) then this wont solve your problem. You can terminate all running Cassini instances by typing (exactly like this because its Case Sensitive): taskkill /f /im "WebDev.WebServer.exe" and hitting enter. You will then see the following message: SUCCESS: The Process "WebDev.WebServer.EXE" with PID <some #> has been terminated.




回答4:


If you have VS2008 and a WEB Application (not WEB Site) you can't have directory named App_Code (you must remove all files from it an move it forexam. to Root folder) and delete/exclude from project that folder (App_Code). Every file you have in App_Code will be compiled during DEBUG/Publish. - this solved my problem with CS0433.




回答5:


I recently fixed that error. The cause is because there are some files or classes declared more than one time in the project. In my case,

error CS0433: The type 'usercontrol_ucManageNews' exists in both 
'c:\Users\DangLe\AppData\Local\Temp\Temporary ASP.NET Files\working\ed64f624\95e2038d\App_Web_kc2c2twy.dll' and 'c:\Users\DangLe\AppData\Local\Temp\Temporary ASP.NET Files\working\ed64f624\95e2038d\App_Web_0ywfoitp.dll'

because in my project there are two folders containing file ucManageNews.ascx




回答6:


The cause MIGHT be that some other DLL's you are referencing might be referencing the older/newer version of the specified assembly. So different parts of the app are referencing different versions of the assembly. I ran into an issue like this as well. In order to resolve it, I forced the app to use the new version:

I changed all of my references in the web.config to point to the newer version. In my case it was the System.Web.Extensions assembly that was causing problems. I changed all of them from 1.0.60125.0 to 3.5.0.0

Next, I added these lines to my web.config, which basically tells your application to "forward" all references to the old version of the assembly, to the new one:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="bin;sitefinity\admin\bin" />
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Telerik.Security" publicKeyToken="dfeaee0e3978ac79" />
        <bindingRedirect oldVersion="3.2.1598.2" newVersion="3.5.1747.2" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Telerik.Cms.Web.UI" publicKeyToken="dfeaee0e3978ac79" />
        <bindingRedirect oldVersion="3.2.1598.2" newVersion="3.5.1747.2" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Telerik.Web.UI" publicKeyToken="121fae78165ba3d4" />
        <bindingRedirect oldVersion="2008.1.515.20" newVersion="2008.2.1001.20" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

I did not come up with this solution, but found it somewhere that I can't remember. However, I don't think I've ever seen an explanation of exactly why this happens either!




回答7:


I just had this problem. It turns out that, I accidentally drag-&-dropped files from one project to another, which created a duplicate. It took me a while to find the problem, because the files were hidden within the Properties folder (which I never look into).

In any case, what helped me solve the problem was going into the file that was throwing the error, r-clicking on the erroneous line and "going to definition". Being in the definition, you can see which physical file you are looking at. If it isn't what it is supposed to be, then you found your problem.

I know this is trivial, but it wasted me around 1 hour of time, so hope this info would be useful to anyone.




回答8:


To fix this bug, it's fairly simple, but requires some rarely used declarations (hard part was digging through the right documentation ;).

See ECMA-334, Section, 16.3 "Extern alias directives"

If you control "your" source and are linking to another assembly "their" binary, yet you can not change (or do not want too change:) the namespace/type specifiers (e.g. BOTH of you declare System). I actually ran into this a fair amount lately, with all the Beta/Alpha/Version updates to the CLR/DLR, MS has been churning a lot in their published namespace's.

When you import assembly "their", typically the compiler will set it up into the global (reserved) namespace. In MSVC, you go to properties on the assembly reference, go to where it say's "Aliases", you can then specify a new name, other than global. Or actually a few names.

Let's say you use the imaginative name of "global2".

You then goto your source files and at the TOP before any namespace declarations, you place;

extern alias global2;
using global2::System;

Your code can then use the types from global2, like "Int32" or whichever, you can still rename it via;

extern alias global2;
using global2::System;
using orig = System;



回答9:


btw, CodeBehind isn't old and not used!

CodeBehind= is for pages in Web Application (with .Designer.cs files) and CodeFile= is for page in Web Site (dynamically compiled assemblies so without .Designer.cs files)




回答10:


I had this issue today with a Web USer Control but discovered that changing CodeBehind="..." to Src="..." is the cause of the error. [link]http://stevenoderayi.blogspot.com/2011/04/resolved-cs0433-type-user-control.html[/link]



来源:https://stackoverflow.com/questions/440675/compile-error-cs0433-on-pre-compiled-asp-net-2-0-site

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!