C# 预编译的 ASP.NET 2.0 站点上的编译错误 CS0433
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/440675/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Compile Error CS0433 on pre-compiled ASP.NET 2.0 site
提问by LarryF
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:
当我启动调试器来调试我的网站时,我经常收到这个错误。我正在使用 Telerik 控件,通常错误出现在我的标签条中。这是我现在正在查看的错误示例:
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\statisticswebc716d3\eebad209\App_Web_6wlqh1iy.dll' and 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticswebc716d3\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.
最让我烦恼的是,如果我一直按 F5,页面将刷新并正常工作。有时需要多次刷新才能做到这一点,而其他情况则发生得很快。我一直无法在网上找到解决方案,因为大多数出现此错误的人正在从 VS2005 升级到 Web 应用程序,因此修复程序似乎是“删除您的 app_code 目录,并将 CodeFile= 更改为 CodeBehind= . 但是,CodeBehind 是旧的,不再使用了。
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.
有没有其他人在预编译页面上看到过这个?我正在使用 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...
我看到的另一个与此相关的效果是,当我使用数据源设置了 GridView,并且数据源发生更改时,但页面直到其他几个操作才更新,然后所有数据一次全部填充...这让我觉得存在某种缓存问题,或编译时、超时或其他什么......
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...
我正在使用 site.master 页面,并检查了 @Page 和 @Master 指令......只是为了论证,这里是它使用的编译器选项......
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\statisticswebc716d3\eebad209\assembly\dl314ff9a5164fc_423cc801\PetersDatePackage.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.IdentityModel.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.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.Common.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticswebc716d3\eebad209\App_Web_0-em44qa.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticswebc716d3\eebad209\App_Web_6wlqh1iy.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticswebc716d3\eebad209\App_Web_ro_sgchs.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\Microsoft.Build.Utilities.0.0.0__b03f5f7f11d50a3a\Microsoft.Build.Utilities.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.ServiceModel.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticswebc716d3\eebad209\assembly\dl3fe979bb<configuration> <system.web> <compilation debug="false" batch="false"></compilation> </system.web> </configuration>
56bc44_4b94c701\Microsoft.Practices.EnterpriseLibrary.Common.DLL" /R:"C:\WINDOWS\assembly\GAC_32\System.Web.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticswebc716d3\eebad209\assembly\dl3\ad70f8ed<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>
10f920_4b94c701\Microsoft.Practices.EnterpriseLibrary.Data.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.ServiceModel.Web.5.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticswebc716d3\eebad209\assembly\dl3\d61e8194extern alias global2; using global2::System;
9ae0bd_854ec901\Telerik.Web.UI.DLL" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticswebc716d3\eebad209\assembly\dl3ba2ae71fb135_e674c901\CoreAPI.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions.0.61025.0__31bf3856ad364e35\System.Web.Extensions.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Management.0.0.0__b03f5f7f11d50a3a\System.Management.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticswebc716d3\eebad209\assembly\dl3fa267e88875e_bb5cc901\AjaxControlToolkit.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\Microsoft.Build.Framework.0.0.0__b03f5f7f11d50a3a\Microsoft.Build.Framework.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Drawing.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticswebc716d3\eebad209\App_Code.nufffrfb.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Services.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticswebc716d3\eebad209\assembly\dl3f6447d\f90fd1c8_b475c901\StatisticsAPI.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.0.0.0__b77a5c561934e089\System.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticswebc716d3\eebad209\assembly\dl35f38e72cdc0f_bc5cc901\Validators.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Runtime.Serialization.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticswebc716d3\eebad209\App_Web_nv7t8gs_.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Data.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Configuration.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Design.0.0.0__b03f5f7f11d50a3a\System.Design.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.WorkflowServices.5.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Mobile.0.0.0__b03f5f7f11d50a3a\System.Web.Mobile.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticswebc716d3\eebad209\assembly\dl3\a5daf5e0extern alias global2; using global2::System; using orig = System;
71b5e7_909cc701\Microsoft.Practices.ObjectBuilder.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.ProcessingObjectModel.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.ProcessingObjectModel.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticswebc716d3\eebad209\App_Web_atcckswk.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Xml.0.0.0__b77a5c561934e089\System.Xml.dll" /out:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticswebc716d3\eebad209\App_Web_zva2jsmk.dll" /D:DEBUG /debug+ /optimize- /win32res:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticswebc716d3\eebad209\zva2jsmk.res" /nowarn:1659;1699;1701 /d:DBCONVERTPUBLIC;CRYSTALSUPPORT "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticswebc716d3\eebad209\App_Web_zva2jsmk.0.cs" "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticswebc716d3\eebad209\App_Web_zva2jsmk.1.cs" "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\statisticswebc716d3\eebad209\App_Web_zva2jsmk.2.cs"error CS0433: The type 'usercontrol_ucManageNews' exists in both 'c:\Users\DangLe\AppData\Local\Temp\Temporary ASP.NET Files\working\ed64f624e2038d\App_Web_kc2c2twy.dll' and 'c:\Users\DangLe\AppData\Local\Temp\Temporary ASP.NET Files\working\ed64f624e2038d\App_Web_0ywfoitp.dll'
Anyone have any ideas where I can even start to look?
任何人都有任何想法,我什至可以开始寻找?
采纳答案by Justin Moore
killing Cassini instances as above didn't work for me. ScottGu posted about this issue
如上所述杀死 Cassini 实例对我不起作用。 ScottGu 发布了关于这个问题的帖子
setting the batch="false" attribute on the compilation section in web.config worked for me.
在 web.config 的编译部分设置 batch="false" 属性对我有用。
##代码##This tells ASP.NET to dynamically compile individual .aspx/.ascx files into separate assemblies. This avoids the circular reference issue that triggers the exception.
这告诉 ASP.NET 将单独的 .aspx/.ascx 文件动态编译成单独的程序集。这避免了触发异常的循环引用问题。
回答by domusvita
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.
对我来说,关闭 IDE、关闭网站(IIS 或 Cassini)、删除我所有的临时 asp.net 文件、启动 IDE 并进行完整编译都可以解决问题。
回答by John Bubriski
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:
原因可能是您正在引用的其他一些 DLL 可能正在引用指定程序集的旧/新版本。所以应用程序的不同部分引用了不同版本的程序集。我也遇到了这样的问题。为了解决它,我强制应用程序使用新版本:
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
我将 web.config 中的所有引用更改为指向较新版本。就我而言,是 System.Web.Extensions 程序集导致了问题。 我将它们全部从 1.0.60125.0 更改为 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:
接下来,我将这些行添加到我的 web.config,它基本上告诉您的应用程序将所有对旧版本程序集的引用“转发”到新版本:
##代码##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!
我没有想出这个解决方案,但在我不记得的地方找到了它。但是,我想我也没有看到过对这种情况发生的确切原因的解释!
回答by John Bubriski
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.
在 IIS 中,您需要通过打开命令提示符并键入iisreset
然后按 Enter来重新启动它,但是如果您使用 Visual Studio Web 服务器(Cassini)中的构建,那么这不会解决您的问题。您可以通过键入(完全像这样,因为它区分大小写)来终止所有正在运行的 Cassini 实例:taskkill /f /im "WebDev.WebServer.exe"
并按回车键。然后,您将看到以下消息:SUCCESS: The Process "WebDev.WebServer.EXE" with PID <some #> has been terminated.
回答by RandomNickName42
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"
请参阅ECMA-334 的第16.3节“外部别名指令”
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. BOTHof 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.
如果您控制“您的”源代码并链接到另一个程序集“他们的”二进制文件,但您不能更改(或不想更改太多:)命名空间/类型说明符(例如,您俩都声明System)。我实际上最近遇到了相当多的问题,随着对 CLR/DLR 的所有 Beta/Alpha/Version 更新,MS 在其已发布的命名空间中进行了大量改动。
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, otherthan global. Or actually a few names.
当您导入程序集“他们的”时,编译器通常会将其设置到全局(保留)命名空间中。在 MSVC 中,您转到程序集引用的属性,转到它所说的“别名”,然后您可以指定一个新名称,而不是全局名称。或者实际上是几个名字。
Let's say you use the imaginative name of "global2".
假设您使用富有想象力的名称“ global2”。
You then goto your source files and at the TOPbeforeany namespace declarations, you place;
然后你转到你的源文件,在任何命名空间声明之前的TOP,你放置;
##代码##Your code can then use the types from global2, like "Int32" or whichever, you can still rename it via;
然后您的代码可以使用 global2 中的类型,例如“Int32”或其他任何类型,您仍然可以通过以下方式重命名它;
##代码##回答by niaher
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).
我刚遇到这个问题。事实证明,我不小心将文件从一个项目拖放到另一个项目,这造成了重复。我花了一段时间才发现问题,因为这些文件隐藏在 Properties 文件夹中(我从未查看过)。
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.
我知道这是微不足道的,但它浪费了我大约 1 小时的时间,所以希望这些信息对任何人都有用。
回答by abatishchev
btw, CodeBehind
isn't old and not used!
顺便说一句,CodeBehind
不旧,不使用!
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)
CodeBehind=
用于 Web 应用程序中的页面(带.Designer.cs
文件)和CodeFile=
用于网站中的页面(动态编译的程序集,因此没有.Designer.cs
文件)
回答by CyNETT
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.
如果你有 VS2008 和一个 WEB 应用程序(不是 WEB 站点),你不能有名为 App_Code 的目录(你必须从中删除所有文件并将其移动到根文件夹)并从项目中删除/排除该文件夹(App_Code)。App_Code 中的每个文件都将在调试/发布期间编译。- 这解决了我的 CS0433 问题。
回答by Steven
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]
我今天在 Web 用户控件上遇到了这个问题,但发现将 CodeBehind="..." 更改为 Src="..." 是导致错误的原因。[链接]http://stevenoderayi.blogspot.com/2011/04/resolved-cs0433-type-user-control.html[/link]
回答by dangle1107
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,
我最近修复了这个错误。原因是项目中有一些文件或类被多次声明。就我而言,
##代码##because in my project there are two folders containing file ucManageNews.ascx
因为在我的项目中有两个文件夹包含文件 ucManageNews.ascx