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

Discussion in 'ASP .Net' started by Hardy Wang, Sep 6, 2006.

  1. Hardy Wang

    Hardy Wang Guest

    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
     
    Hardy Wang, Sep 6, 2006
    #1
    1. Advertising

  2. 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.
     
    Steven Cheng[MSFT], Sep 7, 2006
    #2
    1. Advertising

  3. 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.
     
    Steven Cheng[MSFT], Sep 7, 2006
    #3
  4. Hardy Wang

    Hardy Wang Guest

    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.

    "Steven Cheng[MSFT]" <> wrote in message
    news:9iE6j%...
    > 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.
    >
     
    Hardy Wang, Sep 7, 2006
    #4
  5. 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.
     
    Steven Cheng[MSFT], Sep 8, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?YmNoYXJsZXM=?=

    global.asax and global.asax.cs

    =?Utf-8?B?YmNoYXJsZXM=?=, Oct 4, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    846
    =?Utf-8?B?YmNoYXJsZXM=?=
    Oct 5, 2004
  2. =?Utf-8?B?Tm9OaWNrbmFtZQ==?=

    ASP.NET 2/Global.asax/code-behind/Application_Start

    =?Utf-8?B?Tm9OaWNrbmFtZQ==?=, Nov 9, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    6,343
    Juan T. Llibre
    Nov 9, 2005
  3. Mark Rae

    Global.asax / Global.asax.cs in v2

    Mark Rae, May 23, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    3,172
    Mark Rae
    May 23, 2006
  4. Ron
    Replies:
    13
    Views:
    12,159
    chronisj
    Oct 31, 2008
  5. NoNickname
    Replies:
    2
    Views:
    284
    Bob Barrows [MVP]
    Nov 9, 2005
Loading...

Share This Page