Ich habe heute ein Web "gepublisht" und bekam nachdem ich es online gespielt habe folgende Fehlermeldung:
Beschreibung: Fehler bei der Kompilierung einer Ressource, die zur Verarbeitung dieser Anforderung erforderlich ist. Überprüfen Sie die folgenden spezifischen Fehlerdetails, und ändern Sie den Quellcode entsprechend.
Compilerfehlermeldung: CS0433: Der Typ _default ist in ******\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\7c8d7391\676cfe7\assembly\dl3\e843c292\fe5c4af2_c201c701\App_Web_q6zz6uat.DLL und *******\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\7c8d7391\676cfe7\assembly\dl3\5108e360\d60dfdda_c201c701\App_Web_jxalxmlt.DLL vorhanden.
Ein schnelles Workaround war die .aspx Seite mit der CodeBehind Datei hochzuspielen, danach wurde wenigstens das Web wieder angezeigt.
<%
@ Page Language="C#" MasterPageFile="~/default.master" AutoEventWireup="true" Inherits="_default" CodeFile="default.aspx.cs" %> Die Ursache des Problems liegt in dem Attribute "Inherits" von der Page-Direktive, diese zeigte auf die Masterpage und nicht auf die eigentliche CodeBehind-Datei der eigentlichen Seite. Die Masterpage hieß default.master und hat als inherits="_default". Beim Aufruf der Seite über eine kompilierte DLL wurde die obige Fehlermeldung ausgegeben, welche auch korrekt ist. Komisch ist nur, dass es beim Testen keine Fehlermeldung gibt. Mir ist auch noch völlig schleierhaft, wie dieser Fehler überhaupt passieren konnte. Die Fehlermeldung ist auch nicht besonders aussagekräftig, so dass man nicht weiß wo man suche sollte. So ging es mir jedenfalls...
Irgendwann bin ich dann über folgenden Newsgroup-Beitrag gestolpert, welcher mich auf die Idee gebracht hat.
Autor: Mark Rae
<schnipp>
As we all know, one of the changes in the initial release of ASP.NET 2 was
the deprecation of the CodeBehind Page attribute in favour of the CodeFile
Page attribute:
http://msdn2.microsoft.com/en-us/library/wa20t577.aspx
Fair enough. I'm sure lots of us built brand new ASP.NET 2 websites and
created brand new pages from the Project menu and noticed that the aspx page
had the CodeFile attibute instead of the CodeBehind attribute. Whatever...
However, the ASP.NET development community (hello everyone!) threw its arms
up in horror and said "No, we don't like the new project / site model - we
liked the old project / solution model from v1.1 much better, and we'd like
it back please."
So Microsoft, in a rare moment of actually listening to the development
community, said "OK - here you go - Web Application Projects. And we've even
done Web Deployment Projects for you as well, you lucky people!"
So everyone downloaded and installed the new add-ons and smiled a lot for
they were good.
However, if you build a brand new Web Application Project and create a new
form from the Project menu, you'll see that the aspx Page attribute is
CodeBehind again, not CodeFile...
If you then drop a v2 aspx file from a Web Site Project into a Web
Application Project and FORGET to change its page directive from CodeFile
back to CodeBehind...
Seems the new Web Application Project compilation model doesn't support the
CodeFile page attribute properly, and gets its knickers in a right old
twist... Hence, the double class reference...
</schnapp>
...und siehe da, als ich mir das Inherits näher angeschaut habe, lag die Lösung auf der Hand:
Die korrekte Page-Direktive muss lauten:
<%
@ Page Language="C#" MasterPageFile="~/default.master" AutoEventWireup="true" Inherits="Default" CodeFile="default.aspx.cs" %> Das kann man im Eifer des Gefechts schnell übersehen...
Hier der komplette Newsgroup-Thread, kann ich nur empfehlen
Link