62

Migrating a project from ASP.NET 1.1 to ASP.NET 2.0 and I keep hitting this error.

I don't actually need Global because I am not adding anything to it, but after I remove it I get more errors.

famousgarkin
  • 13,687
  • 5
  • 58
  • 74
Brian G
  • 53,704
  • 58
  • 125
  • 140
  • Possible duplicate of ["Parser Error Message: Could not load type" in Global.asax](https://stackoverflow.com/questions/11682216/parser-error-message-could-not-load-type-in-global-asax) – Michael Freidgeim Jul 25 '17 at 08:19

18 Answers18

85

The reason I encounter this issue is because I change the build configuration. When I set a web project to x86, it changes the output path to bin\x86\Debug. However, the output path should be bin and the web server won't find the binaries because of this.

The solution thus is to change the output path of the website back to bin after you change the build configuration.

Pieter van Ginkel
  • 29,160
  • 8
  • 71
  • 111
  • 29
    +1 This is probably the single greatest answer ever provided on stack overflow. Words alone do not suffice in expressing my gratitude for this exceptionally helpful, superbly worded answer. Cries of joy rang out a half a world away when this answer was both read and applied with magnificent levels of success and sincere sensations of relief. A cold beer has especially been set aside for our dear, dear guide, Pieter. May you sir, live a very long and very happy life. An absolutely marvellous contribution. Just marvellous. Thank you. – rism May 19 '12 at 10:29
  • 6
    Thanks. New Zealand is a bit of a drive for me, but if I'm ever in the vicinity, I'll take you up on it. – Pieter van Ginkel May 24 '12 at 06:20
  • I would like to add my congratulations on this most excellent answer. – Rob Jul 23 '12 at 14:23
  • Oh ya, I would have never found that on my own... THANKS! – Erikest Jul 26 '12 at 17:27
  • I echo rism's comment. Thanks – B4ndt Jul 27 '12 at 11:11
  • 1
    Our problem was the install project had the Primary Output pointed at a "bin" folder, so its compiled dll ended up in \site\bin\bin. Different root cause, but the same result. Odd that nothing in ProcMon or the fusion logs pointed us to the cause. – Pedro Oct 01 '13 at 20:19
57

There are a few things you can try with this, seems to happen alot and the solution varies for everyone it seems.

  • If you are still using the IIS virtual directory make sure its pointed to the correct directory and also check the ASP.NET version it is set to, make sure it is set to ASP.NET 2.0.

  • Clear out your bin/debug/obj all of them. Do a Clean solution and then a Build Solution.

  • Check your project file in a text editor and make sure where its looking for the global file is correct, sometimes it doesnt change the directory.

  • Remove the global from the solution and add it back after saving and closing. make sure all the script tags in the ASPX file point to the correct one after.

  • You can try running the Convert to Web Application tool, that redoes all of the code and project files.

  • IIS Express is using the wrong root directory (see answer in VS 2012 launching app based on wrong path)

Make sure you close VS after you try them.

Those are some things I know to try. Hope one of them works for you.

Community
  • 1
  • 1
pete blair
  • 1,607
  • 1
  • 17
  • 14
  • 1
    yeah i have used those over time and one of them would usually resolve the issue. – pete blair Oct 24 '08 at 18:28
  • 1
    Removing and re-adding Global.asax is what did the trick for me. – East of Nowhere Aug 15 '12 at 21:15
  • My Bin and Obj folders were excluded from the project... just used the "Show all files" button in solution explorer, then right clicked and included those folders. Thanks. – kad81 Oct 28 '13 at 09:49
  • 3
    @kad81 Bin and Obj folders _should_ stay excluded from the project. – Bora Jan 15 '14 at 13:41
  • yep thanks man. worked a treat. i had cleared out my bin directory for another issue but didnt notice i had the build set to something other than debug – nologo May 12 '15 at 05:59
  • +1, this still fixes it in 2017. I had to remove the global.asax and global.asax.cs files, save and close out of visual studio, re-open the solution, clean the solution, and build and run it. All is well once again! – Lews Therin May 02 '17 at 13:03
  • Check if your bin is excluded in Project.If yes, Please include that in the Project and it worked for me. – Praveen Kumar Rejeti Nov 06 '18 at 14:17
5

Deleting the existing global.asax file and adding a new one, clears out this error. This has worked for me many times.

user1444662
  • 51
  • 1
  • 1
5

I've found that it happens when the Global.asax.(vb|cs) wasn't converted to a partial class properly.

Quickest solution is to surround the class name 'Global' with [square brackets] like so (in VB.Net):

Public Class [Global]
    Inherits System.Web.HttpApplication
    ...
Mark Glorie
  • 3,733
  • 3
  • 28
  • 31
3

If your using visual studio 2010 this error can occur when you change the configuration deployment type. The 3 types are x86, x64 and Mixed mode. Changing to mixed mode setting for all projects in solution should resolve the issue. Don't forget to delete the bin, Lib files and change the tempdirectory output if your an ASP.NET website.

bhrionn
  • 31
  • 2
2

This just happened to me and after trying everything else, I just happened to notice on the error message that the app pool was set to .Net 1.1. I upgraded the app to 2.0, converted to web application, but never changed the app pool:

Version Information: Microsoft .NET Framework Version:1.1.4322.2490; ASP.NET Version:1.1.4322.2494

Doug Lampe
  • 1,426
  • 15
  • 8
2

This one drove me completely insane and I couldn't find anything helpful to solve it. This is probably not the reason most people have this issue but I just hope that someone else will benefit from this answer.

What caused my problem was a <clear /> statement in the <assemblies> config section. I had added this because in production it had been required because there were multiple unrelated applications on the same hosting plan and I didn't want any of them to be affected by others. The more correct solution would have been to have just used web config transforms on publish.

Hope this helps someone else!

MitchellKrenz
  • 423
  • 4
  • 14
2

Changing the address's port number (localhost:) worked for me :)

rebulanyum
  • 487
  • 10
  • 21
2

I fixed this error by simply switching from Debug to Release, launch program (It worked on release), then switch back to Debug.

I tried just about everything else, including restarting Visual Studio and nothing worked.

fix
  • 1,425
  • 16
  • 27
1

In my case, a AfterBuild target in the project to compile the web application was the reason for this error.

See here for more info

Community
  • 1
  • 1
MichelZ
  • 4,214
  • 5
  • 30
  • 35
1

Removing Language="c#" in global.asax file resolved the issue for me.

mahesh reddy
  • 367
  • 3
  • 10
1

In my case, I was duplicating an online site locally and getting this error locally in Utildev Cassini for asp.net 2.0. It turned out that I copied only global.asax locally and didn't copy the App_code conterpart of it. Copying it fixed the problem.

user173399
  • 464
  • 5
  • 21
1

I had this same problem installing my app to a server. It ended up being the installer project, it wasn't installing all the files needed to run the web app. I tried to figure out where it was broken but in the end I had to revert the project to the previous version to fix it. Hope this helps someone...

campo
  • 1,872
  • 1
  • 17
  • 19
1

When you try to access the Microsoft Dynamics NAV Web client, you get the following error. Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 This error can occur when there are multiple versions of the .NET Framework on the computer that is running IIS, and IIS was installed after .NET Framework 4.0 or before the Service Model in Windows Communication Foundation was registered.

For Windows 7 and Windows Server 2008, use the ASP.NET IIS Registration Tool (aspnet_regiis.exe,) to register the correct version of ASP.NET. For more information about the aspnet_regiis.exe, see ASP.NET IIS Registration Tool at Microsoft web site.

try this solution https://www.youtube.com/watch?v=LNwpNqgX7qw

Eng.Bassel
  • 99
  • 2
  • 12
0

Ensure compiled dll of your project placed in proper bin folder.

In my case, when i have changed the compiled directory of our subproject to bin folder of our main project, it worked.

Devendra Patel
  • 309
  • 2
  • 10
0

Had this error in my case I was renaming the application. I changed the name of the Project and the name of the class but neglected to change the "Assembly Name" or "Root namespace" in the "My Project" or project properties.

ascriven
  • 362
  • 3
  • 6
0

Deletin obj, bin folders and rebuilding fixed my issue

cahit beyaz
  • 4,829
  • 1
  • 30
  • 25
0

I had this problem.

I solved it with this solution, by giving CREATOR OWNER full rights to the Windows Temp folder. For some reason, that user had no rights at all assigned. Maybe because some time ago I ran Combofix on my computer.

bgmCoder
  • 6,205
  • 8
  • 58
  • 105