Last post Jan 29, 2009 09:51 AM by brettemiller
Aug 02, 2006 01:08 AM|Don A|LINK
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:
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.
Aug 02, 2006 06:23 PM|Baiju|LINK
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?
Aug 03, 2006 10:48 AM|Don A|LINK
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.
Aug 03, 2006 07:04 PM|Don A|LINK
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.
Aug 27, 2008 03:13 AM|TATWORTH|LINK
Did you completely resolve your problem?
Jan 29, 2009 09:51 AM|brettemiller|LINK
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:
I removed the
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?
"could not load type global"