after uploading my project to server i am getting following error please let me know what is the following error
CS0433: The type 'Course' exists in both 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\672b2bdf\9fb2ad98\assembly\dl3\afaf3b67\f1871969_3e5bcb01\App_Code.DLL' and 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\672b2bdf\9fb2ad98\assembly\dl3\29fd4e0e\f1751c7e_3e5bcb01\App_Web_spb4jssk.DLL'
and
Line 111: [System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()]
Line 112: public class admin_course_aspx : global::Course, System.Web.SessionState.IRequiresSessionState, System.Web.IHttpHandler {
Line 113:
Line 114: private static bool #__initialized
and
Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\672b2bdf\9fb2ad98\App_Web_course.aspx.fdf7a39c.gdurkajz.0.cs
Line: 112
It looks like you may have a Web Site, and not a Web Application Project.
For a Web Site, you get a lot of arbitrarily named .DLLs, such as your "App_Web_spb4jssk.DLL" above. These names are different every time you compile.
What's probably happening is that when you add your new dlls to your production server, the old one (with a different name) is still there, and contains the same class names as your new ones.
What you have to do is delete everything in the bin directory of your production server before you upload your new ones.
Ideally, what you should do is convert your web site to a Web Application Project.
Update:
Here is an article that describes how to convert a website into a web application project. It's specific to VS2005, but the steps are basically the same for VS2008 and VS2010.
The difference between a website and a web application project is that in a web application there is a project file that keeps track of all the files and settings for your website, just like for any other Visual Studio project. A web application will also compile your entire site into just one dll.
If you have a web site that doesn't have a project file, it doesn't explicitly know how you want to compile your website, so it ends up creating a bunch of separate dll files with random names.
I would also recommend what Claudio says. However, you may want to double check that you don't have any source files in the App_Code directory that were erased in your local copy (as they were moved into a different DLL)
Related
In the old asp.net project, there is a published .cs file in one of the folders. When I update the site, I update the .dll files, but this file is never updated. When I delete this .cs, the site does not work. How do I delete this file?
Are you using a asp.net web site applcation to publish, or are you using a asp.net web site?
As a general rule, if you using asp.net web site applcation, then the source code files are NOT required to be up-loaded.
However, you left out one big detail. Where is that cs file? While a asp.net web site will attempt and does pre-compile all code, ONE BIG exception to this rule exists.
That is the folder app_code. That folder is in fact compiled by IIS, and as a result, if that file is in that folder, it will have to be included in your publish.
In fact, when I started using the newer Roslyn compiler (I liked it VERY much for allowing me to have longer free text such as SQL in the code as strings).
However, IIS did not and does not have Roslyn compile by default. And my code was breaking.
So, as a result, I simple create my own folder called MyCode. And you could do the same. Note that each code module (vb.net) or static class for your general shared code routines do have to be marked manually as to compile.
eg this:
So, if your .cs file is in app_code, then you can move it out, drop it into a folder you create, and set the file build action to compile, and of course do not copy.
However, and this is a HUGE big "if". If your deployment model is web site as opposed to web site applcation, then this will not work, since IIS is doing your compile after deployment, as opposed to pre-compiling the code BEFORE deployment.
So, you are in luck if your .cs file is (or was) in app_code, since then as noted, you can move that out of app_code, and in properties set the file to be compiled, but not deployed. This as noted will only work if you deploying as a asp.net web site applcation as opposed to a asp.net web site.
I am using Visual Studio 2017, and the application target .net framework is 4.5.2.
This application ABC (to which I am providing an enhancement) is already deployed and functioning pretty well.
Now that I have to only perform changes on 1 page (a simple condition change), I am planning to deploy only App_Web_xxxx in the ".\bin" folder.
After publishing the application using the "Precompiled" configuration, I was able to identify the respective App_web_xxx.dll file and copied in App. Server bin folder. Renamed it according to existing requestEdit.aspx file. All looks good till now, and interestingly, this App_Web_xxx.dll is common for multiple aspx files available under a common folder (users/request).
Once I try executing this code by accessing the website (respective aspx.cs UI file), it gives the error:
"Could not load assembly "App_Web_xxx.dll", make sure that it is compiled before accessing the page".
But the issue is This dll file doesn't break for any other aspx page available under the User/request folder, it is failing only for feature I modified.
What I have done apart from above mentioned way (considering usual way of partial deployment process):
Replaced requestEdit.aspx page and added new dll, by keeping old dll as is (which can be used by other aspx pages in deployment folder)
Error changed to:
Could not load assembly 'App_Web_xxx.dll, version=0.0.0.0, Culture=neutral, Publickey Token=null' or one of its dependencies.The system cannot find the file specified.
Replaced requestEdit.aspx page and added new dll, by removing old dll and renaming App_Web_xxx.dll in "Imports = Default.aspx, App_Web_xxx.dll" in all required aspx files (for which the old dll was removed)
If I am replacing the whole solution (except web.config) the solution works fine with no issues, the only problem comes when I am replacing only 1 .dll file.
All the solutions I found are providing information of IIS version or dll copying from Server to Dev, but my problem is I'm publishing on dev env (local machine) and partially deploying on the server.
Need help to resolve this issue as this is really inconvenient to deploy the whole solution just for 1 condition change!
Additional Info:
Page Properties --> MSBuild Options --> Allow this Precompiled site to be updatable (checked)
I have created an upload program that I'd like to sell but not give the source code out. I have published this on my web server and had no problems.
I compiled it and went to the bin directory and copied the contents to another folder on my web server. Tried to access it and got this:
Server Error in '/' Application.
--------------------------------------------------------------------------------
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 'AspxUpload.Default'.
Source Error:
Line 1: <%# Page Language="C#" AutoEventWireup="true" Inherits="AspxUpload.Default" Codebehind="Default.aspx.cs" %>
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: /u/default.aspx Line: 1
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1016
I'm rather new to asp.net, but I know what an application pool is. Can a program written in asp.net not be copied directly to the server and be expected to run?
I was testing what I was going to place in a zip file as a test but this will not run 'out of the box'.
What am I doing wrong or what am I missing?
UPDATE
Just for clarification, I'd like to be able to copy the contents of my zip into a directory and have it work without having to create an application pool, if that is feasible. Like I was saying, I was hoping to make this an 'out of the box' solution.
Is this possible with Asp.net?
====== UPDATE #2 ======
I found out that, in IIS, if I right click on the folder where the app is and convert to an Application, it works fine.
Do all asp.net apps need to be converted to an application if not published?
I have also updated the error message from the server where the website resides.
From what you're saying you might be trying to add an application within your application pool. If you publish your entire application to a folder, then zip it, you should be able to publish the contents of that folder to any web hosting (folder) that is configured as an asp.net application.
So when talking of out of the box software, in most cases when someone takes out web hosting for asp.net it will come configured as an application on the root directory. If this is where the file is unzipped to then it should work fine but if they use a subfolder within the root, then this may need to be converted to a web application.
In my experience some hosting companies will only allow a certain amount of configured web apps, and in a lot of cases only one, so this is worth considering if they app needs to be added under another directory.
Please have a look at this post to get around your issue.
http://blogs.msdn.com/b/robgruen/archive/2005/09/12/464196.aspx
I don't know why you would need to move the folder but first check that your web.config is in the root and that it has the appropriate access rights.
Then check any other folders for other web.config files or do a search for it in the application.
It sounds like an issue with either a duplicate web.config or that is missing.
Depending on the version of Visual Studio you have, you can use the "Publish" command. Have the application published to a package, which is a .zip file which can be imported by IIS 7 and above (at least, if you have the Web Deploy feature installed).
Publishing can not only save the application, but also IIS configuration if you're using IIS locally for your web application, and you can even deploy a database.
In addition, you can use web.config transforms to vary the web.config based on the build configuration. So that, if your publishing settings are for your "Test" build configuration, the package will contain the result of building with the "Test" configuration, as well as the result of applying "Web.test.config" to "Web.config" to produce a Web.config modified for your Test environment.
VS 2010, .NET 4.0, VB, EF 4.4
I was having issues deploying my web application to the server... was getting the error "Could not load type " when I tried running it on the server. Googling around I also found that my Web App should not have an "App_Code" folder (copied over shared but of code from other corporate Web Sites). So I moved all the classes from App_Code to a folder off the root ("BLL" - also the namespace of our code library).
Now when I run the app in the VS IDE I'm getting the error "Configuration Error. Could not load type 'BLL.Roles'" coming from the load of the web.config. If I add the assembly name of the app to the front of the "BLL.Roles" > "appName.BLL.Roles" I get past this line and error out at the next reference to "BLL".
I've Cleane and Rebuilt my project.
Why are my classes not getting recognized as part of the app?
I could be wrong but i believe because you are using a Web Site and not a Web application you can only access classes that live in the App_Code Folder. If you are working with a Web Application you can access classes no matter what folder they live in. In that case you might have to move your files to a new project that is under a Application format and not a Web Site format. I would try to move your files to a Web Application project.
I am new to Visual Studio and ASP.NET. I have a MyClass.cs file under App_Code directory, but could not able to run the function in the class file. Keep getting this error:
The name 'MyClass' does not exist in the current context
I know that code works fine since I posted the codes and others confirmed it works, but I am still receiving the error above.
I read alot more threads on the NET and somes indicated that problem is using Web Application Project instead of Web Site project, which the class file would not compile. I am not sure if I've created it under Application Project we Web Site project.
How can I tell that my site is running under Web Application Project or Web Site Project? and How can I change it to Web Site Project so my class can be recognized.
Thanks in advance,