Application model compile error:Could not load type 'Upgrade.Global'.

Last post 01-29-2009 9:51 AM by brettemiller. 5 replies.

Sort Posts:

  • Application model compile error:Could not load type 'Upgrade.Global'.

    08-02-2006, 1:08 AM
    • Member
      15 point Member
    • Don A
    • Member since 08-02-2006, 4:31 AM
    • Posts 3

    Hi,

    I'm converting a 1.1 app to 2.0 using the application model rather than the project model. I get the compile error "Could not load type..." on the Global.asax file:

    Error 1 Could not load type 'Upgrade.Global'. C:\Inetpub\wwwroot\Upgrade\Global.asax 1 

    The contents of the asax file are:

    <%

    @ Application language="C#" Codebehind="Global.asax.cs" Inherits="Upgrade.Global" %>

    I added the language clause (it wasn't needed for 1.1) since pressing F1 on the error message displays a generic VB error help.

    A bit of history: In order to test the migration, we created a new web app in iis called Upgrade and copied our current project source files into it and then ran the application project migration. I also had to do several "Replace in Files" to change the namespace and directory paths from our current project to the Upgrade project.

    I've verified that the namespace is set to Upgrade. I noticed that the word "Global" is displayed in a different color in the codebehind file. Is this a reserved word now in 2.0? I tried using a different class name to no avail. I've seen other posts where people are getting this same error in the project model - they say to move the global.asax code to the App_Code directory. Since this is an application model project, there is no App_Code directory. 

    Any help would be greatly appreciated.

    Thanks! 

  • Re: Application model compile error:Could not load type 'Upgrade.Global'.

    08-02-2006, 6:23 PM
    • Participant
      990 point Participant
    • Baiju
    • Member since 09-17-2002, 3:07 PM
    • Posts 198

    Class name Global is fine for C#.  Did you ran 'Convert To Web Application' context menu after converting the project file to WAP Project model?

    Baiju

     

    "This posting is provided "AS IS" with no warranties, and confers no rights"
  • Re: Application model compile error:Could not load type 'Upgrade.Global'.

    08-03-2006, 10:48 AM
    • Member
      15 point Member
    • Don A
    • Member since 08-02-2006, 12:31 AM
    • Posts 3

    No, I didn't use the context menu. Per the instructions for the WAP model, after installing, I just opened the 1.1 project from within VS 2005 and it walked me through the migration. None of the App_xxx project model directories were created like it did the first time I tried this. When I decided to try the application model, I wiped out the test directory used for the migration and started from scratch.

    Additional info. This has nothing to do with Global.asax. I tried to exclude it from the project and I got the same error on the first file in the workspace. I then excluded that file, and I got the same error on the next one. So, something else is going on here. I looked in the references and saw that there was a reference to the original project, so I removed it to no avail. From what I've read, you can get this error if the system has already loaded this type. Without more info from the error message, I don't know where to look.

    Thanks for the help.

    Don

  • Re: Application model compile error:Could not load type 'Upgrade.Global'.

    08-03-2006, 7:04 PM
    • Member
      15 point Member
    • Don A
    • Member since 08-02-2006, 12:31 AM
    • Posts 3

    I think I may have resolved this.

    When I created the Upgrade project from our original project, I evidently didn't update all that I should have such as the namespace, dll name, etc.in the project settings. These still had the original project name. I also tried to "get by" without being able to load the Upgrade app in iis - I had assumed it was some other configuration problem outside of visual studio. Bad move.

    After getting the Upgrade project to build and load in iis, I ran the conversion. I had to drop and re-add  a reference to another project on my first build attempt. As soon as I did that I got 383 errors and 53 warnings but the info in the error messages is enough for me to work with. For a lot of the errors, they are duplicates, so once I fix it, the number should drop quickly. I'm no longer seeing the "Could not load type..." error message, thank goodness.

    Once we get the current build to compile successfully and run, I think we'll use the Convert to Web Application context menu that you mentioned above to convert to using partial classes. Previously, I wasn't sure where that menu came into play.

    Thanks again and sorry for the trouble.

    Don

  • Re: Application model compile error:Could not load type 'Upgrade.Global'.

    08-27-2008, 3:13 AM
    • All-Star
      63,000 point All-Star
    • TATWORTH
    • Member since 02-04-2003, 8:34 AM
    • England
    • Posts 12,308
    • TrustedFriends-MVPs

    Did you completely resolve your problem?

    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: Application model compile error:Could not load type 'Upgrade.Global'.

    01-29-2009, 9:51 AM
    • Member
      18 point Member
    • brettemiller
    • Member since 09-26-2006, 3:45 PM
    • Boston
    • Posts 8

    Hey, put this in the "for what it's worth bin": 

    I, too struggled with this.  I spent a few hours rebuilding my app, removing references and re-installing asp.net.  Nothing worked.  What could possibly have changed???!!  Well, upon the advice of this discussion:

    http://forums.asp.net/p/1088894/2492262.aspx

    I removed the

    Inherits="Global" 

    attribute from global.asax, and the compiler moved on. My problem bacame apparent: I had accidentally dragged the App_Code folder into the App_Themes folder. Doh!

    I corrected the problem and put the Inherits attribute back into global.asax (even though it doesn't appear to be necessary) and the solution built just fine. So, my advice if you see this error: you may have some kind of structural problem with your solution.  Verify that your class files are where you expect them to be?

     Good luck!

     --Brett

Page 1 of 1 (6 items)