Reputation: 1649
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?
Upvotes: 155
Views: 199607
Reputation: 61
At Dev Server -
Use AnyCPU in Solution Plateform and build again.
Please refer this screenshot.
Upvotes: 0
Reputation: 1015
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.
Upvotes: 2
Reputation: 22857
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 Views\Web.config could also be at fault.
Upvotes: 4
Reputation: 3657
I was receiving the parser error after right clicking and excluding the global.asax from my Web API 2 solution.
It turns out that rather than just excluding it, you have to right click and delete it.
After deleting I no longer get the parser error.
Upvotes: 0
Reputation: 958
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.
Upvotes: 2
Reputation: 4514
Make sure all your own referenced dlls have "Copy Local" set to True in the Properties window, unless they are in the GAC. There is no need to do this with framework dlls.
Upvotes: 0
Reputation: 11730
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 bin\debug but the web project doesn't work unless the output path is set to simply "bin"
Upvotes: 171
Reputation: 757
I have also faced the same issue and somehow IIS Express's config file is not pointing to the correct bin directory for the website. So editing the Config file which will be in Documents/IISExpress/config fixed the issue. Just point to the correct physical path in Site tag as shown below.
<site name="MYWEBSITE" id="4">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="D:\MYWEBSITE" />
</application>
<bindings>
<binding protocol="https" bindingInformation="*:44305:localhost" />
<binding protocol="http" bindingInformation="*:6689:localhost" />
</bindings>
</site>
Upvotes: 0
Reputation: 251
I got this error when trying to add a service reference to a workflow service. And eventually I had to add this to my web.config.
As you can see, I added it after the Final Entity Framework tag and before the final configuration tag.
</entityFramework>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8006/Sample/Service1.xamlx"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
contract="ServiceReference1.IService" name="BasicHttpBinding_IService" />
</client>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Upvotes: 0
Reputation: 31
I resolved this by switching my project properties from Web>>Specific port>>55555 to Auto-assign port
Upvotes: 0
Reputation: 1
After spend almost 2 hour I resolve this Issue by just delete a line from .csproj file.
<PlatformTarget>AnyCPU</PlatformTarget>
Upvotes: 0
Reputation: 81
I solved my problem by renaming lots of things. If your problem is cause by creating a new project from copying an existing project like me, you may try these steps.
some of these steps may be worthless, but following them all should solve your problem.
Upvotes: 0
Reputation: 5444
If Andy Copley's answer worked for you but simply rebuilding the solution doesn't work, then go to Project | Project Dependencies and make sure that the project that has your Global.asax.cs file in it is dependent on all the other non-test projects in the solution.
Upvotes: 0
Reputation: 345
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.
Upvotes: 5
Reputation: 11
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.
Upvotes: 1
Reputation: 4993
Here's another one:
I hope that helps someone somewhere :)
Upvotes: 3
Reputation: 2492
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.
Upvotes: 0
Reputation: 61
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.
Upvotes: 0
Reputation: 71
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.
Upvotes: 0
Reputation: 336
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.
Upvotes: 1
Reputation: 1
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.
Upvotes: 0
Reputation: 783
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')
Upvotes: 2
Reputation: 11
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.
Upvotes: 1
Reputation:
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.
Upvotes: 0
Reputation: 1148
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:
Cheers.
Upvotes: 4
Reputation: 9
Follow these steps:
Upvotes: 0
Reputation: 2927
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.
Upvotes: 2
Reputation: 81
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!
Upvotes: 8
Reputation: 241
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.
Upvotes: 24
Reputation: 6883
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.
Upvotes: 0