I am developing an asp.net web application and i have a problem with Global.asax file,
when i publish my website and upload it to server the Global.asax is missed, it will be gone to bin folder and Reshape to Dll file.
but it does not work!
and when i uploaded the Global.asax file to the root folder it works but i have an other error like this
Compiler Error Message: CS0433: The type 'ASP.global_asax' exists in both 'c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\93c82a26\eca26fde\assembly\dl3\b8f9aab8\18e0a0de_5afccf01\App_global.asax.DLL' and 'c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\93c82a26\eca26fde\App_global.asax.o53z7epf.dll'
protected ASP.global_asax ApplicationInstance {
get {
return ((ASP.global_asax)(this.Context.ApplicationInstance));
and its not possible to clear the temp folder because there will be on other error, please help me.
The problem occurred in a virtual application's bin folder. When you look into this bin-folder you will probably see two files (an information I found here):
App_global.asax.dll
App_global.asax.compiled
Removing these resolves the error. The App_global.asax.dll is generated at runtime too which causes the problem.
Related
I created an ASP.Net project in .Net 2.0 and uploaded all files to the server (dlls and cs files) to the server. It is a very basic HTML page with a button on it.
When I loaded it on the server, it was okay.
I added a static class to my project and used it when the button was clicked:
protected void btnUse_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(txtData.Text))
Utils.SaveData(txtData.Text);
}
When I uploaded it, I get the following error:
Server Error in '/' Application. Compilation Error Description: An
error occurred during the compilation of a resource required to
service this request. Please review the following specific error
details and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'Utils' does not exist in the
current context
What else should I upload?
The code change can't take effect until the code is compiled, and the result is the .dll file(s). So two things to take care of here:
In order to add the class, you need to add it to the source code (which you've done), re-compile into the .dlls, and upload the new .dlls to the server.
You don't need (and shouldn't have) the .cs files on the server. That's the source code, not the compiled result. The compiled result is the .dlls. The server needs those, the markup pages (.aspx, .ascx, etc.), and any other resources (images, JavaScript files, .css files, etc.), but not the C# source code.
I created a project (ASP.NET empty web application) WebApplication1.
I also have Default.aspx/login.aspx/GoogleCallBack.aspx
when I run the application, the error shows
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 'WebApplication1.Global'.
Source Error:
Line 1: <%# Application Codebehind="Global.asax.cs" Inherits="WebApplication1.Global" Language="C#" %>
Source File: /global.asax Line: 1
Does anyone know how to fix it ? thank you
Just Check Project -> Properties -> Web
Project Url --- Click on (Create Virtual Directory)link => This will ask you to map to correct folder location say ok.
This problem Occured when we move our project to different directory and IIS still refers to old directory.
Does your project have a "Global.asax.cs"? If so, does it compile?
F5 is for "Debug." This is about building the solution. Ctrl+Shift+B would be the hot-key combination to build and look for compiler errors.
This topic is a duplicate of "Parser Error Message: Could not load type" in Global.asax.
The most voted answer is provided by Facio Ratio: Your local web server is running different code than what you're actually working on. Ensure you have stopped debugging, stop your local web server, clean and rebuild as Peter suggested, double-check your global.asax and global.asax.cs, and try again. If this doesn't work and you are using local IIS, try removing the site in IIS Manager and recreating it manually.
I have currently moved my asp.net 4.0 web application onto IIS7 (windows 2008 server). I used a test folder to hold files from a directory on the localhost machine, however; when I moved the aspx file over and changed the code(on the server), the application keeps throwing this error
Could not find a part of the path 'C:\Users\***\Desktop\TestFolder\'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\****\Desktop\TestFolder\'.
I only have two functions that deal with directories and neither function points to that test directory anymore.
private int checkForFileNumbers()
{
string url = "c:/***/realfolder";
DirectoryInfo directory = new DirectoryInfo(url);
return directory.GetFiles().Length;
}
private void checkForFiles()
{
string url = "c:/***/realfolder";
DirectoryInfo dir = new DirectoryInfo(url);
foreach (FileInfo files in dir.GetFiles())
{
FileDropDownList.Items.Add(files.Name);
}
}
I have tried commenting everything in this aspx file out, only to find that this problem still occurs. I performed the issrestart from the cmd line and nothing changed. Any help would be appreciated.
This is a deployment problem. Your error message is clearly out of sync with your current code. The actual code that is being run from IIS must be coming from an out-of-date binary. As a starting point, I would delete all DLLs in your bin directory on the server and redeploy fresh DLLs. The may also require you to refresh your aspx files depending on what kind of project type you're using.
Once you get this sorted out, I would take another look at how you are deploying updates to your site. Visual Studio and IIS 7 offer some neat deployment options if you want to go that way. Also, you could deploy via Git or SVN. But deployment by manual replacing single files is going to lead you to the type of trouble you are currently experiencing.
If realFolder directory exists under root of your web-app or itself is root then use Server.MapPath method to get real path of virtual folder.
For instance,
String rootPath=Server.MapPath("~"); // It will return real path of current web-app's root.
//OR - In case if want use Server property from separate code file.
String rootPath=HttpContext.Current.Server.MapPath("~/testFolder");
Since you're not referencing the path in your code, it's probably either in one of your config files, HttpModules, Global.asax, or perhaps a DLL.
What other components are you using?
Before moving it to a server, have you tried running the site under IIS on your local machine? Maybe attach a debugger and see where the error is thrown?
Oh, FWIW, the IIS AppPool identity will need to have read permission for your C:/***/whatever folder.
Scenerio: I have an asp.net website that I am compiling successfully but keep getting an error in the browser saying that it can not find a referenced dll in the solution. I checked the directory in the Temporary ASP.NET File location and all of my referenced dll's are there except for the one it is failing to retrieve. I manually added the location it was looking for and the site worked.
The dll is referenced in code so it should have been moved to the temp folder. Does anyone have any idea why this would happen? I checked the properties on the referenced dll and copy local is set to true so it should be moved to the output directory.
Right click on the DLLs in your References/Bin directory in your project and look at the Copy Local property. Make sure they are set to True.
After hours of searching google and finding nothing, I decided to take a look at the actual properties of the dll file. To my surprise the issue ended up being permissions. For some reason the one dll that was beating me up all day needed correct permissions to be moved to the output folder. ughhh.
When you say "referenced in code" do you mean it's listed in the project file's Reference section? Or do you mean you are manually referring/naming it in your source code?
Have you tried this in your web.config (or higher up the config chain?)
<hostingEnvironment shadowCopyBinAssemblies="false" />
Where exactly are you expecting it to be copied? What is the path the error message is reporting?
I've got a C# 3.5 web service that works fine when its accessed at http://domain/foo/bar/WS.asmx
The /foo/bar part could change in the future so I want to give people a more stable URL that I could update without requiring any changes from them. I created a site in IIS and set it's Home Directory to where WS.asmx is. Now when I try to access it from http://domain2/WS.asmx, I get:
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 create
type 'Namespace.WS'.
Source Error: Line 1: <%# WebService
Language="C#" CodeBehind="WS.asmx.cs"
Class="Namespace.WS" %>
The assemblies in both cases are at http://domain/bin but when I come from domain2 it doesn't seem to know where to find the \bin that is 3 folders up in the file system.
The namespace/classes are more descriptive than that, I just made them basic for the purposes of this question.
Sorry, AFAIK you can't pull DLLs from explicit file paths outside the root of your website. You generally have two choices:
1) use the /bin directory of the current app (make a copy of the other app's /bin)
2) put the DLL into the Global Assembly Cache (GAC)
BTW, this has been asked in a few other spots on SO, like here.
One thing you could do, if your /bin DLLs are only used inside /foo/bar/, is to convert into an IIS application, and then move the DLLs into a new /foo/bar/bin directory. Then you'd only have one copy of the DLL's to manage.