I have started to work on a ASP.NET MVC Unity web project that is building and running successfully for my peers, however when I attempt to run the project I get the following Parser Error that references line 1 of my Global.asax file:
"Parser Error Message: Signature of the body and declaration in a
method implementation do not match."
This error can be avoided by removing the reference to
IContainerAccessor and the inherited container property from
Global.asax.cs.
When I try to debug the problem by putting a breakpoint at the beginning of Application_Start, the build will still work but I receive the error page without hitting the breakpoint.
This problem persists even after getting exactly what is working for others via source control. I am not sure what else I can try, any help is greatly appreciated.
Two reasons for that error message:
1 Your local web server is running different code than what you're
actually working on:
to fix that try this:
stop debugging.
stop your local web server
clean and rebuild
You might need to re-create the Virtual Directory.
2 Your local project is pointing to a a dll library version that is different than the one in the source control
I am trying to get a different server side stack functioning with my ASP.NET site. My ashx file seems to be throwing a 500 Internal Server Error. How do I figure out what exception this ashx file is throwing or the reason the 500 is being thrown? When I attach to my IIS 7 w3wp.exe process, it doesn't throw an exception, but I'm reading that this is likely the case.
The ashx file lives in the root directory of my ASP.NET site, and the Properties have it set to compile.
GET http://uhc-8:8883/MyApp/ExtDirectProxy.ashx 500 (Internal Server Error) index.html:27
Uncaught TypeError: Cannot read property 'isProvider' of null ext-all-debug.js:74832
allow right click initializing for http://uhc-8:8883/MyApp/index.html rightclick.js:1
allow right click processing http://uhc-8:8883/MyApp/index.html rightclick.js:25
If you have a folder called "App_Code", you can go through headaches
and migranes. Or simply replace "App_Code" with some random name like
"code" or "data" and put your classes in there to fix this. In my
case, my project GUID was a Web Application and C# type.
Best Answer:
App_Code folder issues
Note:
I am running the site using IIS with a static port, not using Visual Studio 2012 with a dynamic port. I have specific server configuration on the web server, so I want the site to behave the same way our released site works. So that's why I run it like that.
Answer to my question:
This occurred because we had duplicate versions of the App_Data classes in the bin folder. The "Compile" version of the *.cs, and the website version of the *.cs. The “isProvider” error happens when more than one class with the same name exists. When we deploy the ASP.NET application, we deploy ONLY the compiled version of the *.cs files. The development environment, we keep them set to Properties > Build Action > None.
Not sure of an easy way around that. It might have to do with having things in the temporary and/or obj folder, but not sure exactly. Will take a little more troubleshooting to discover why. In the mean time, here is a list of things to resolve the issue. Not sure if some or all of these were necessary, but it's working now.
Steps to fix:
change all App_Data *.cs files to Properties > Build Action > Compile
Fix exceptions they throw to get that build working again - Clean Solution > Build Solution ... one exception was not caught with those set to Properties > Build Action > None, so that's why this was necessary. Essentially, Visual Studio 2012 does not throw an exception and says "Build Successful".
then change App_Data *.cs files back to Properties > Build Action > None
remove dlls out of \obj\Debug
remove dlls out of \bin
remove temporary ASP.NET files - C:\WINDOWS\Microsoft.NET\Framework\{.NET version}\Temporary ASP.NET Files\
Build Solution
restart IIS web site
Now things work great!
EDIT:
Actual problem was that I was referencing an external project in Visual Studio, but there was no dll file for it because the project type was Console Application, not Class Library. The real problem was that Visual Studio says it compiles the code fine (in App_Code) when you have a using statement to that other project, but says Built Successfully, even when the Build Action > Compile option is set for all *.cs files in App_Code. When you run the web application, it has to be set back to Build Action > None for it to work. However, since the *.cs files in App_Code didn't actually compile with the new code (if that's how ASP.NET in IIS treats these App_Code *.cs files), it throws the 500 Internal Server error because there's no good CIL code during runtime. To solve it, I just changed the project type to Class Library, and it still has no errors, but now it can reference the dll to the other project.
The isProvider error always occurs when there are duplicate classes found. So I'm not sure why that occurs, but that essentially goes away once you fix the part above.
You can use the Application_Error event in Global.asax file to catch that error.
protected void Application_Error(Object sender, EventArgs e)
{
HttpContext ctx = HttpContext.Current;
Exception exception = ctx.Server.GetLastError();
int httpCode = ((HttpException)exception).GetHttpCode(); // check if it is 500
}
I am experiencing an error that I am unable to resolve for some time now. I was wondering if someone can help identify the cause of this error? I am completely new to asp / asax. After some research, I think that the error I am getting is due to the web application trying to use outdated code. I was thinking to rebuild the c# file using Visual Studio and/or the entire project. However, I am completely new to C# and asp, and was wondering can give me some suggestions if this may fix the problem and/or if there is an possible alternate solution.
Error message
Parser Error Message: Could not load type 'Inventory1.Global'.
Source Error: <%# Application Codebehind="Global.asax.cs" Inherits="Inventory1.Global" %>
Entire Global.asax contents:
<%# Application Codebehind="Global.asax.cs" Inherits="Inventory1.Global" %>
Try replacing CodeBehind with CodeFile
Could not load type
means that a type could not be loaded. (In this case, "type" refers to Inventory1.Global). Types are located in compiled DLLs. So, either the DLL isn't available, is out of date, or doesn't contain a public type with the given name.
Some possible causes are:
You have no type declared with the given name. For your example, you should have the following:
namespace Inventory1 {
public class Global {
...
}
}
Note: avoid names like Inventory1. They imply that there is an Inventory2, Inventory3, etc., which is bad practice as they're abmiguous and not very descriptive. Also, Global is pretty vague, and may introduce confusion with the global namespace.
Make sure your cases match (Inventory1, not INVENTORY1.)
You haven't compiled the project. In VS, rebuild the solution.
The assembly that declares the class has a compilation error, so the relevant DLL is either missing or out of date. Make sure you've resolved all errors.
The class is not marked as public.
If I had to guess, I'd put my money on a compilation error. Unlike PHP and other interpreted languages, C# have to be successfully compiled before they can be used.
I had this error , just needed to rebuild the project
I faced this issue and i got the solution from here and i would like to share it.
SOLUTION
Empty the bin folder. Build all the dependent class libraries and refer them in the main project and build the complete solution.
I did this and it worked like a charm for me !!
After scouring around for what could have caused this I found a few things that I needed to do to get my project running...
(Note: You may not need to do all of these - it is a case-by-case thing)
If you did any changes from IIS Express to Local IIS you may need to change the build configuration from bin/debug to bin. (Right click on solution >> Properties >> Build >> Output)
If you have a URL rewrite then you will need to install URL rewrite on your Local IIS.
Navigate to your applicationhosts.config file (usually it's some place like C:\Users\username\Documents\IISExpress\config) and rename the file to applicationhostsOLD.config.
Clean and rebuild your project. You may need to go manually empty out the bin.
Now you should be good to go.
Since it was only happening with IISexpress, changing output from bin\Debug\ to bin\ solved it for me. Changing tag CodeBehind to CodeFile only created even more problems.
This happened with me on my local machine. The issue was incorrect IISExpres config.
If you are getting this issue on your local environment (Visual Studio debug runs), check the IIS Express config file. Make sure your local site/application path is pointing to the correct location.
The configuration file is called applicationhost.config. It's stored here:
My Documents > IIS Express > config . Usually (not always) one of these paths will work:
%userprofile%\documents\iisexpress\config\applicationhost.config
%userprofile%\my documents\iisexpress\config\applicationhost.config
It can't find the necessary file in dll assembly.
Rebuild the project, Rebuild the solution and then try it again.
I added a new build profile and that defaulted to output of
/bin/[new profile name] and when i was running debugger it was trying to look to just /bin
It's likely that you renamed something. Check the Global.asax.cs file for the class declaration and make sure that the namespace and class name match exactly what's in the asax file. This includes case! Can you copy/paste the namespace and class declaration of the .cs file into a post here so that we can compare?
Parser Error Message: Could not load type __
After doing everything suggested in the comments above, with no luck, refreshing (uploading) the contents of /bin to the server worked. The files uploaded to bin are the: dll, pdb and xml. Don't know which one did it.
The problem I had here was induced by renaming a file (_.aspx) in Solution Explorer.
Rebuilding/re-publishing my project/solution to the server did nothing to help me, and I doubt that will help that many out of this predicament. For me, I did a few things to troubleshoot this that eventually got me out of this "hole".
I had been trying to use a binding on the web site, but this wasn't working. I tried calling the site with http://localhost/Report.aspx (this was my homepage, which I opted to not call Default.aspx - I was going to update the "Default Documents" section with the name later) when I got the Parser Error the OP saw. So I tried some things:
I stopped the old project's website and built another, simple web project, that had "hello" and a label on the page and nothing else. I had a line in the Page_Load to populate the label's Text property with "world!", just to make sure that part was working. I created a new website on port 80 and transferred the published contents of my site to the server. So even though I had .NET 4.5 installed on the server (and had ran the aspnet_regiis -i command from the 4.0 directory) and the App Pool in IIS that I was using for this new project was set to 4.0, the browser complained about the web.config having a targetFramework=4.5.2 in it, which is Visual Studio 2015's default framework. So I installed .NET 4.6 (NDP46-KB3045557-x86-x64-AllOS-ENU.exe), restarted the server, and then my simple site worked. So then I deleted this site - all I wanted to do was prove my installation steps were accurate and the server could run a site.
So then I went back to my original project/site - I deleted and re-created the web site. I put the Application Pool to the one I had originally created for this, which I ensured was running .NET 4.0. Once I did this, I navigated to my site and everything worked when using http://localhost/Report.aspx. So it seems to me what causes this is what version of the .NET Framework you are using.
I tried all the solutions listed above and none of them worked. I finally created a new web page (webform) and copy blocked all the code (cs and aspx files) into it from the old one, deleted the old cs and aspx file, recompiled, and now I'm back in business. I know it makes no sense. It should not have mattered, but it worked.
Please try to open your project as Project/Solution, most probably it will resolve the error. This type of error Could not load type.... occurs when we try to open project as website.
I have tried to open my project as solution and it resolved my problem.
Please check namespace and class name at all places, In one case, One team member changed namespace and I was using old namespace in .aspx file. It was causing issue. I updated namespace and it got working.
I was fixing my namespaces in our Base Project, and I started seeing this error on another project that references it after that. I had to remove the reference to the Base Project and re-add it and then it started working again.
I just got this error today. It turns out that it was because I reverted by mistake the project file to an older version that didn't include the page anymore.
I had the same issue after renaming an aspx page Visual studio renamed it but dropped the namespace. Make sure the Inherits property contains the fully Qualified name including the namespace.
If you just added the new aspx File, rebuild the project it is located in. The problem comes from your Code Behind file that isn't compiled at the moment, therefore you want to access a newer page that doesn't exist in your current compiled project dll
I had this problem on the remote server, but not on my local server. After trying everything and nothing working, I finally resolved it. My domain name was pointing to a directory under another domain. I had originally built the website independently in Visual Studio as its own project. No matter what I did, it wasn't working anymore. So I moved it to a folder inside of the project for the main domain name and uploaded it as part of the main project.
For example, I have say domain name AAA.com with a website of its own. And then I also have BBB.com that points to a directory under AAA.com's main directory. Originally I had separate VS projects for AAA.com and BBB.com, but that wasn't working anymore. So I had to move all of BBB.com's files to the AAA.com project and set it up exactly like it appears on the remote server. For some reason, that worked.
Try This It will Definitely work :-
Parse Error:
May be you Class name is not matched with the webform name
I'm having this problem last Friday when I'm trying to build my project to deploy it.
Whenever I build my project (Ctr+Shift+B or F6) I always encounter this kind of error.
When I'm trying to locate the file from my PC it looks like it reside in temporary folder and when building my project, this files automatically created.
Anyone encountered this kind of problem?
You have an unclosed #region statement (or perhaps some other syntax error) in the .aspx or .cshtml file that is generating that code.
check if everything matches...
then use project properties to set properties of output exe.
Then use build solution to build the project.
You Will fine output exe in debug>bin folder
I have a ASP.NET project and when building the project it is showing build suceessfull. But when I am building the deployment project, it is showing build failed with an error message
Error 5 "aspnet_compiler.exe" exited with code 1
I rechecked my project and found that when i am removing the line <!--#include file="admin/topstyle.asp"-->, it is working fine. If I use this line, I am getting error building web deployment project to create my dll.
topstyle.asp is a file which render some common styles for the page like heading image and all.
Can anyone tell me how to get rid of this problem?
You can't mix ASP.NET and ASP in the same page. The ASP.NET compiler is returning an error because it doesn't understand the ASP code.
As for why the project builds okay, that's because include-directives are a function of the webserver, not Visual Studio or even ASP.NET. When you build in Visual Studio, the include is ignored because the compiler doesn't even know what it is (it just sees it as an HTML comment), so the compiler only sees the ASP.NET code and the HTML... but when the page is compiled on the fly, the webserver first brings in the included files and then passes the entire thing to the compiler, and the compiler then falls over when it encounters the included ASP code.
Following changes in vb.net code solved the Error "aspnet_compiler.exe" exited with code 1". The solution was build successfully but the publish failed.
The solution was build successfully but the PUBLISH FAILED with error "aspnet_compiler.exe" exited with code 1".
The Following changes in VB.NET code solved this error:
PREVIOUS CODE:
dtRow.Item("ParentGroupName") = Session("SecondaryGroupItems").GetSecondaryGroupItem(Session("LgItems").GetLgItem(mFnTransaction.FnTransactionDetails(1).LgId).SecondaryGroupId).Name
NEW CODE:
Dim mmSecondaryGroupId As Integer = 0
Dim mmLgId As Integer = 0
mmLgId = mFnTransaction.FnTransactionDetails(1).LgId
mmSecondaryGroupId = DirectCast(Session("LgItems"), LgItems).GetLgItem(mmLgId).SecondaryGroupId
dtRow.Item("ParentGroupName") = DirectCast(Session("SecondaryGroupItems"), SecondaryGroupItems).GetSecondaryGroupItem(mmSecondaryGroupId).Name
Does it work successfully on other pages? Also is the Topstyle.asp page a ASP.NET page? If not it will not work as you can't mix the two technologies like that.
In ASP.NET the include syntax is discouraged. Try using a user control instead, or the <%= Globals.MyConstantThatContainsTheStyles %>.
If you are using ASP 2.0 look at using Master Pages, but that might be a big change for your app.
I've found that the compiler sometimes has issues with absolute paths in include directives. Don't know if it solves this particular problem, but whenever possible, try to use <!-- include virtual="~/page.asp" --> instead.