I am getting the following error on one of our production servers. Not sure why it is working on the DEV server?
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.Parser Error Message: Could not load type ‘TestMvcApplication.MvcApplication’.
Source Error:
Line 1: <%@ Application Codebehind=»Global.asax.cs» Inherits=»TestMvcApplication.MvcApplication» Language=»C#» %>
Source File: /global.asax Line: 1
Not sure if anybody came across this error before and how it was solved, but I have reached the end.
Any help would be appreciated.
I also need to mention that this is the published code, so all is compiled.
Can there be something wrong with my compiler settings?
p.campbell
97.4k67 gold badges255 silver badges319 bronze badges
asked Oct 21, 2009 at 5:07
4
None of the other answers worked for me. I fixed my error by changing the web project’s output path. I had had it set to bindebug but the web project doesn’t work unless the output path is set to simply «bin»
answered Oct 13, 2011 at 18:16
Brian LeemingBrian Leeming
11.5k8 gold badges30 silver badges52 bronze badges
10
I’ve had this a couple of times. It’s especially frustrating as it’s right off the bat, and the error message holds no clue as to what might be the issue.
To fix this, right click your project title, in this case «TestMvcApplication» and click build.
This forces the code to compile before you run it. Don’t ask me why, but this has been the solution 100% of the time for me.
answered Feb 12, 2010 at 14:39
7
I have found that when you are forced to use the Configuration Manager to run under x86 or anything other than the standard project «out of the box» settings, the IDE creates a bunch of sub directories under the bin folder for the web project.
Once this starts happening, if the Cassini server is running, then the project does not serve properly.
I fixed it by going into the Web Project properties -> Build settings and changing the Output Path to be bin
Then rebuild and all works as it should.
answered Nov 14, 2011 at 23:52
DamoDBearDamoDBear
2412 silver badges2 bronze badges
4
I tried all above solutions but no luck. Adding line <add assembly="*" />
to web.config fixed it for me. (You can also add to machine.config or root web.config file of the appropriate .NET framework version, I didn’t try it) Thanks to MS Support for solution.
answered Jun 13, 2011 at 18:27
Manish JainManish Jain
9,4895 gold badges39 silver badges44 bronze badges
2
After a long hard look I came accross the real issue here.
The assemblies were corrupted by the FTP client I used to upload the files to a hosted environmet.
I changed my FTP client and all is working as intended.
answered Oct 21, 2009 at 18:31
0
I had the same problem: mine was because the web project had a platform target of x86. I was running on a 64-bit machine; other projects in the solution were set to 64-bit.
To check your settings, right click the project and choose Properties. On the Build tab, check the value of «Platform Target».
Also check your solution’s build configuration (Build menu > Configuration Manager) to check all your projects are being built to the same platform.
In both cases, make sure you check the settings both for debug and release mode — otherwise you’ll get it working on your machine but not when you deploy it!
answered Jan 13, 2011 at 10:47
teedyayteedyay
23.1k19 gold badges65 silver badges73 bronze badges
1
I had what looked like the same error. I tried many suggestions from many pages only to find out the problem was that I had the website set to the wrong version of .Net
No matter how many re-compiles or people saying ‘configuration problem’, nobody made the point that the .net version needed to be checked.
answered Aug 9, 2011 at 16:27
IT happens with me when I rename my project/solution.
Go to the folder of project in windows explorer (get out of VS).
Find and open the file Global (maybe you’ll find 2 files, open that dont have «.asax.cs» extension), and edit the line of error with correct path.
Good luck!
answered Nov 18, 2011 at 21:02
PauloPaulo
811 silver badge1 bronze badge
1
I experienced the exact same problem a couple of days ago — as far as I can tell it was an issue with a 64-bit IIS running a 32-bit web application. We changed our production server to 32-bit and this issue disappeared.
answered Dec 3, 2009 at 14:05
Jaco PretoriusJaco Pretorius
24.7k11 gold badges60 silver badges94 bronze badges
Make sure your default namespace in the web project properties is the same as the namespace in the Global.asax.cs. I had modified the default namespace to make it a subnamespace, changing it back fixed this issue for me.
answered Apr 16, 2014 at 16:05
Ace HyzerAce Hyzer
3453 silver badges10 bronze badges
0
For completness sake I included what my issue was and how I solved it:
If your like me and have httphandlers via web.config and you have redirects from your global.asax.cs (maybe in Session_Start() ) like in my case you get this error if your startup project does not have a reference defined which points to the target where your httphandler is pointing!! (but you wont get build errors, just runtime errors)
So:
- Double check your web.config for any external items
- Double check your startup project has all the references it needs.
Cheers.
answered Apr 11, 2013 at 20:24
ChrisChris
1,00015 silver badges25 bronze badges
1
The only time I have experienced this was when the MVC framework was not installed on the server. Could that be the case?
A missing Pages section in ViewsWeb.config could also be at fault.
Undo♦
25.4k37 gold badges109 silver badges128 bronze badges
answered Oct 21, 2009 at 5:09
Daniel ElliottDaniel Elliott
22.5k10 gold badges64 silver badges82 bronze badges
2
I had the same error and none of your solutions helped. I think my problem was simply the name that I had chosen for the project. I had named my project ‘interface’ which when I got the parse error it said that it couldn’t load:
Line 1: <%@ Application Codebehind=»Global.asax.cs» Inherits=»@interface.MvcApplication» Language=»C#» %>
Where there was an ‘@’ sign for some reason. I am guessing the word ‘interface’ is reserved for something else and it added the @ symbol but that obviously broke something. I deleted the project and made a new one with a different name with no problems.
agf
167k42 gold badges283 silver badges234 bronze badges
answered Aug 12, 2011 at 16:26
Here’s another one:
- I had been working on a web api project that was using localhost:12345.
- I checked out a different branch from source control containing the same project.
- I ran the project on the branch and got the error.
- I went to «Properties > Web > Project Url» and clicked «Create Virtual Directory»
- A dialog came up telling me that the url was mapped to a different directory (the directory for the original project).
- I clicked Okay and the virtual directory was remapped.
- The error went away.
I hope that helps someone somewhere
answered Mar 4, 2014 at 19:13
grahamesdgrahamesd
4,6831 gold badge26 silver badges27 bronze badges
1
I had a lot of problems and errors to solve, some of the above answers helped, but what the final trick that made it work for me was: Go to your project, click properties.
Go to the Package/Publish Web tab and make sure the configuration is set to Release and Platform to All Platforms.
Last make sure that the «Items to deploy (applies to all deployment methods)» is set to «All files in this project folder»
It then worked fine for me.
answered Jul 13, 2011 at 14:20
This issue is complicated because it’s easy to confuse the root cause with whatever the immediate cause happens to be.
In my case, the immediate cause was that the solution is configured to use NuGet Package Restore, but the server was not connected to the internet, so NuGet was unable to download the dependencies when building for the first time.
I believe the root cause is simply that the solution is unable to resolve dependencies correctly. It may be an incorrect path configuration, or the wrong version of an assembly, or conflicting assemblies, or a partial deployment. But in all cases, the error is simply saying that it can’t find the type specified in global.asax because it can’t build it.
answered Mar 4, 2013 at 19:47
shovavnikshovavnik
2,8683 gold badges24 silver badges21 bronze badges
Make sure that the Namespace in the Global.asax
file matches that in the Global.cs
file i.e.
Global.asax: Some.Website.Webapplication
Global.cs: Some.Website
(minus the ‘WebApplication’)
Jay Walker
4,6345 gold badges47 silver badges53 bronze badges
answered Aug 8, 2013 at 20:16
TheDaveJayTheDaveJay
7436 silver badges11 bronze badges
I tried most of the above answers and they didn’t work. For some reason just closing and reopening VS fixed the problem for me.
answered Feb 4, 2016 at 20:43
Rochelle CRochelle C
8983 gold badges10 silver badges22 bronze badges
My issue was solved when I converted in IIS the physical folder that was containing the files to an application. Right click > convert to application.
mortb
9,0613 gold badges25 silver badges43 bronze badges
answered Dec 10, 2014 at 20:55
jayt.devjayt.dev
9696 gold badges14 silver badges36 bronze badges
For me, it was because I had temporarily excluded the file from the project. I merely included it in back in the project and then it worked.
answered Jun 20, 2013 at 14:11
1
In my case reference of System.Web.MVC was missing from my project. But after adding references issue was same so i checked properties of my Bin folder it was ReadOnly. Just after making it writable,everything working fine.
answered Nov 20, 2013 at 10:42
yashpalyashpal
3261 gold badge3 silver badges16 bronze badges
I was getting error because I deployed the application as a virtual directory and I was was getting parser error «could not load type» then I deployed the application as a web site and i was not getting that error again.
answered Mar 5, 2014 at 22:08
None of the other answers resolved this error for me.
I did find a solution that worked, which I suggest for those in the same situation:
- Close Visual Studio
- Browse to ProjectsyourProjectyourProject
- Rename Web.Debug.config and Web.Release.config
- Rebuild and run your application
ahsteele
26k27 gold badges138 silver badges247 bronze badges
answered Jun 20, 2011 at 16:42
Charles BurnsCharles Burns
10.2k7 gold badges66 silver badges81 bronze badges
1
I never really did get to the bottom of what was causing it for me. I think somewhere I must have been missing some files. I got the error after publishing to a new server. Eventually I copied the site from working site. Then the site worked and so did further publishes to the new server.
answered Oct 14, 2011 at 14:57
Giles RobertsGiles Roberts
6,2576 gold badges47 silver badges63 bronze badges
Follow these steps:
- Build
- Configuration Manager
- Put the AnyCPU project
- Back to generate
- Ready, after this just follow the same steps to pass it to x86 or x64
Jesse
8,5157 gold badges46 silver badges57 bronze badges
answered Apr 10, 2013 at 20:56
For me, I had a DLL included with my project that had to be run in a 32-bit environment.
The server was configured to run the website in 32-bit mode, but I was not able to run the application on my 64-bit machine because the localhost
folder had not been specified to run in 32-bit mode.
answered May 24, 2013 at 18:47
jp2codejp2code
26.3k40 gold badges154 silver badges268 bronze badges
I just had a similar problem.
The reason was that I was changing a file.aspx.c and had to do a clean rebuild. After that everything worked.
answered Oct 10, 2013 at 11:13
My problem was that I was trying to create a ASPX web application in a subfolder of a folder that already had a web.config file, and
So I opened up the parent folder in Visual Studio as a Web Site (Open > Web Site) I was able to add a new item ASPX page that had no issue parsing/loading.
answered Dec 5, 2013 at 19:55
For me, the problem was only on certain (long) links within the website and was tracked down to URLScan having the default configuration of a URL length limit of 260.
answered Dec 17, 2013 at 23:58
JamesJames
613 bronze badges
I’ve had the same issue.
Try to:
Right click on the project and select Clean, then right click on it again and select Rebuild and run the project to see if it worked.
answered Jan 2, 2014 at 12:54
da Rocha Piresda Rocha Pires
2,4241 gold badge24 silver badges19 bronze badges
Error Description:
Parser Error Description: An error occurred during the parsing of a resource required to service this request.
- Parser Error Message: Could not load type ‘TestMvcApplication.MvcApplication’.
- Source Error:
- Line 1: <%@ Application Codebehind=»Global.asax.cs» Inherits=»TestMvcApplication.MvcApplication» Language=»C#» %>
- Source File: /global.asax Line: 1
Solution 1:
- Running the project from Visual Studio works fine. This is the source code from Global.asax:
namespace WebApplication5
{
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
}
}
click below button to copy the code. By — .Net tutorial — team
- This leads us to believe that we might not have something install or some configuration is not correct that IIS sets globally.Here is what steps we followed for a new web application in Visual Studio 2015:
- File -> New Project -> ASP.NET Web Application -7gt; MVC
- Runed the project on visual studio it works with the default templates
- On IIS we created a new website and in that website we created a new web application which is mapped to the folder of the project.
- we created an application pool for the newly created project inside the website that has the following configuration.
- .NET CLR versions is set to .NET CLR Version v4.0.30319
- Managed Pipeline is set to integrated
After doing all this we tried the following to fix the issue:
- Clean and Rebuild for Visual Studio
- Restart Visual Studio Clean Rebuild an PC Reset Clean rebuild
- we made sure that the project adds its assemblies in the bin folder
- we made sure that in Solution ->Properties -> Configuration Properties the proejct is set to debug
- we made sure that the namspace in Global.asax xml file points to the correct type in Global.asax.cs
Solution 2:
- We had this a couple of times and the error message holds no clue as to what might be the issue.
- To fix this, right click our project title, in this case «TestMvcApplication» and click build.
- This forces the code to compile before we run it. this has been the solution 100% of the time for all.
Solution 3:
Here’s another one:
- We had been working on a web api project that was using localhost:12345.
- We checked out a different branch from source control containing the same project.
- We ran the project on the branch and got the error.
- we went to «Properties > Web > Project Url» and clicked «Create Virtual Directory»
- A dialog came up telling me that the url was mapped to a different directory (the directory for the original project).
- we clicked Okay and the virtual directory was remapped.
- The error went away.
Solution 4:
- We need to read the Python Unicode HOWTO. This error is the very first example.
- Basically, stop using str to convert from unicode to encoded text / bytes.
- Instead, properly use .encode() to encode the string:
p.agent_info = u' '.join((agent_contact, agent_telno)).encode('utf-8').strip()
click below button to copy the code. By — .Net tutorial — team
or work entirely in unicode.
Solution 5:
This is a classic python unicode pain point! Consider the following:
a = u'batsu00E0'
print a
=> batsà
click below button to copy the code. By — .Net tutorial — team
All good so far, but if we call str(a), let’s see what happens:
str(a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'xe0' in position 4: ordinal not in range(128)
click below button to copy the code. By — .Net tutorial — team
To fix the error, encode the bytes explicitly with .encode and tell python what codec to use:
a.encode('utf-8')
=> 'batsxc3xa0'
print a.encode('utf-8')
=> batsà
click below button to copy the code. By — .Net tutorial — team
- The issue is that when we call str(), python uses the default character encoding to try and encode the bytes we gave it, which in our case are sometimes representations of unicode characters.
- To fix the problem, we have to tell python how to deal with the string we give it by using .encode(‘whatever_unicode’).
- Most of the time, we should be fine using utf-8.
Learn dotnet — dotnet tutorial — server error in app — dotnet examples — dotnet programs
Could Not Load Type ‘xxxxxxx.xxx.UI.Admin.Test’ — ASP.NET 2.0 Error and Solutions
When an .aspx page of ASP.NET 2.0 Web Application is viewed, at times we get the error «Could not load type xxxx’. The sample error message displayed is as follows
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load type ‘xxxxxxx.Web.UI.Admin.Test’.
Source Error:
Line 1: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="xxx.Web.UI.Admin.Test" %>
Line 2:
Line 3: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/ DTD/xhtml1-transitional.dtd">
Source File: /Test.aspx Line: 1
There are several reasons why we get the error. We will present you the major reasons why we get the error and also how to correct them
Reason 1: Invalid Build Output Directory
If the build output folder of the web application is set to any folder other than Bin, you would get this error. For example pointing the build output folder to ..CommonBin or C:Bin is not a valid configuration and this invalid configuration causes the Could not load type error.
To solve the error always point your output folder of the web application project to bin
Reason 2: Referring to Code Behind Modules Without Building The Application
If you refer to any code behind module in .aspx pages or Global.asax page and the web application has’nt been built then you get this error.
To solve the error, build the web application using Build option(Ctrl+Shift+B) available in Visual Studio.NET development environment or use command line compilers like CSC.
Refer to Microsoft support page for elaborated information
Reason 3: Incorrect asp.net version configuration in IIS
Incorrect asp.net version configuration in IIS server also causes this error. For example, if you are using Visual Studio 2005 with an IIS configured with ASP.NET v1.1 is an invalid configuration.
In order to solve the problem follow these simple steps
- Go to Start Menu, click on Run (alternatively use Win Key + R )
- Type INetMgr and press enter to open Internet Information Services Application
- Expand the tree node displaying local computer name and navigate to Web Sites—>Default Web Site
- Right click on Default Web Site node and select the popup menu option Properties
- Navigate to ASP.NET tab in the properties page and set the version to 2.xxxx(for Visual Studio 2005) or 1.xxxx(for Visual Studio 2003)