Home All Groups Group Topic Archive Search About

ASP.NET 2.0: Global.asax code-behind and web deployment project problem

Author
6 Sep 2006 9:43 PM
Hardy Wang
Hi all,
    In order to solve code-behind of global.asax problem, I removed the code
from global.asax, and just leave one line "<%@ Application Language="C#"
Inherits="Global"%>" in this file. Then I created a CS file in App_Code
folder named Global.asax.cs:

public class Global : System.Web.HttpApplication {
void Application_OnError(object sender, EventArgs e) {
        // my own complex error handling logic
    }
}

When I debug locally, it can jump into this function whenever some error
happens.

Then I added a Web Deployment Project to my solution, and merged all DLLs
into one, I copied all my files to web server. BUT when I run the web
server, I got following error

Compiler Error Message: CS0433: The type 'ASP.global_asax' exists in both
'c:\WINNT\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\root\0059d51c\80906b1d\App_global.asax.gyayxcqz.dll' and
'c:\WINNT\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\root\0059d51c\80906b1d\assembly\dl3\3e64f089\c486205e_fcd1c601\MyWebProject.DLL'

It seems that Web Deployment Project compiles global.asax as well, so that
there are 2 classes named "Global" existing in assemblies.

Who knows what is the solution to solve this problem? I cleared all
temporary files, it doesn't help at all.

I am mad.....

--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy

Author
7 Sep 2006 5:36 AM
Steven Cheng[MSFT]
Hello Hardy,

From your description, I understand you're using the VS 2005 "Web
Deployment Project" add-on project to precompile an ASP.NET 2.0
application. However after the compilation and try running the precompiled
the application, you're getting type loading error against the
global.asax's codebehind class, correct?

As for this issue, based on my experience, it is related to the how the web
application is precompiled (through webdeployment project or not).  Have
you configured the precompiled site to be updatable or have you configured
the web deployment project to precompile the application into multiple
assemblies?

As for the global.asax file, based on my local test, if you use "web
deployment project" to precompile the web site, the output compiled
application directory will not include the "global.asax" file in it, this
is because the global.asax is only needed by the ASP.NET runtime and after
precompilation, there will output an "App_global.asax.compiled" file in the
"bin" directory which identify the assembly which contains the class to
serve the request to global.asax.  (see below)

=====================
<?xml version="1.0" encoding="utf-8"?>
<preserve resultType="8" virtualPath="/DeployWebApp/global.asax"
hash="f424386" filehash="fffff5d6110aa691" flags="150000"
assembly="DeployWebApp_deploy" type="ASP.global_asax">
  <filedeps>
    <filedep name="/DeployWebApp/global.asax" />
  </filedeps>
</preserve>
=====================

Therefore, there should not exist "global.asax" file in the precompiled
output application's directory.  Is this the case in your scenario? 

Please feel free to let me know if there is anything unclear or if you have
different settings as I mentioned.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
Are all your drivers up to date? click for free checkup

Author
7 Sep 2006 1:52 PM
Hardy Wang
Hi Steven,
    Thanks for your reply. I attached my setting of my web deployment
project.

    When I deployed my web project yesterday, I manully copied the
global.asax to web server, and did not copy App_global.asax.compiled file. I
did it just now, and it worked! I seems I need to do a research of
pre-compile.

Show quoteHide quote
"Steven Cheng[MSFT]" <stch***@online.microsoft.com> wrote in message
news:9iE6j%23j0GHA.228@TK2MSFTNGXA01.phx.gbl...
> Hello Hardy,
>
> From your description, I understand you're using the VS 2005 "Web
> Deployment Project" add-on project to precompile an ASP.NET 2.0
> application. However after the compilation and try running the precompiled
> the application, you're getting type loading error against the
> global.asax's codebehind class, correct?
>
> As for this issue, based on my experience, it is related to the how the
> web
> application is precompiled (through webdeployment project or not).  Have
> you configured the precompiled site to be updatable or have you configured
> the web deployment project to precompile the application into multiple
> assemblies?
>
> As for the global.asax file, based on my local test, if you use "web
> deployment project" to precompile the web site, the output compiled
> application directory will not include the "global.asax" file in it, this
> is because the global.asax is only needed by the ASP.NET runtime and after
> precompilation, there will output an "App_global.asax.compiled" file in
> the
> "bin" directory which identify the assembly which contains the class to
> serve the request to global.asax.  (see below)
>
> =====================
> <?xml version="1.0" encoding="utf-8"?>
> <preserve resultType="8" virtualPath="/DeployWebApp/global.asax"
> hash="f424386" filehash="fffff5d6110aa691" flags="150000"
> assembly="DeployWebApp_deploy" type="ASP.global_asax">
>  <filedeps>
>    <filedep name="/DeployWebApp/global.asax" />
>  </filedeps>
> </preserve>
> =====================
>
> Therefore, there should not exist "global.asax" file in the precompiled
> output application's directory.  Is this the case in your scenario?
>
> Please feel free to let me know if there is anything unclear or if you
> have
> different settings as I mentioned.
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
>
> ==================================================
>
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
> ications.
>
>
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscriptions/support/default.aspx.
>
> ==================================================
>
>
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>

[attached file: 1.jpg]
Author
7 Sep 2006 2:28 PM
Steven Cheng[MSFT]
Thanks for your reply Hardy,

Yes, the ASP.NET 2.0 percompilation has many particular settings. And those
generated files like the xxxx.precompiled is necessary , so you need to
copy them together with other assemblies in "bin" directory.

Anyway, I'm glad the suggestion has been helpful.  If you need any further
help, please feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.
Author
7 Sep 2006 6:43 PM
Hardy Wang
Sorry, my mistake. It still doesn't work.

I try to run a fake ASPX page to trigger an (404) error to let Global.asax
to capture, it worked.

When I loaded my normal ASPX page, I had same error again.

Show quoteHide quote
"Steven Cheng[MSFT]" <stch***@online.microsoft.com> wrote in message
news:9iE6j%23j0GHA.228@TK2MSFTNGXA01.phx.gbl...
> Hello Hardy,
>
> From your description, I understand you're using the VS 2005 "Web
> Deployment Project" add-on project to precompile an ASP.NET 2.0
> application. However after the compilation and try running the precompiled
> the application, you're getting type loading error against the
> global.asax's codebehind class, correct?
>
> As for this issue, based on my experience, it is related to the how the
> web
> application is precompiled (through webdeployment project or not).  Have
> you configured the precompiled site to be updatable or have you configured
> the web deployment project to precompile the application into multiple
> assemblies?
>
> As for the global.asax file, based on my local test, if you use "web
> deployment project" to precompile the web site, the output compiled
> application directory will not include the "global.asax" file in it, this
> is because the global.asax is only needed by the ASP.NET runtime and after
> precompilation, there will output an "App_global.asax.compiled" file in
> the
> "bin" directory which identify the assembly which contains the class to
> serve the request to global.asax.  (see below)
>
> =====================
> <?xml version="1.0" encoding="utf-8"?>
> <preserve resultType="8" virtualPath="/DeployWebApp/global.asax"
> hash="f424386" filehash="fffff5d6110aa691" flags="150000"
> assembly="DeployWebApp_deploy" type="ASP.global_asax">
>  <filedeps>
>    <filedep name="/DeployWebApp/global.asax" />
>  </filedeps>
> </preserve>
> =====================
>
> Therefore, there should not exist "global.asax" file in the precompiled
> output application's directory.  Is this the case in your scenario?
>
> Please feel free to let me know if there is anything unclear or if you
> have
> different settings as I mentioned.
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
>
> ==================================================
>
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
> ications.
>
>
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscriptions/support/default.aspx.
>
> ==================================================
>
>
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
Author
8 Sep 2006 1:46 AM
Steven Cheng[MSFT]
Thanks for your followup Hardy,

I'm sorry to hear that the problem remains. In order to get a clear view,
is it convenient that you create a simplified project with global.asax and
some simple pages which can reproduct the error? If so, I can perform some
local test agaist them.  You can touch me through the email in my
signature(by remove "online").

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



This posting is provided "AS IS" with no warranties, and confers no rights.

Bookmark and Share