Related
I am working on an ASP.NET Web Forms site that is written completely in C#. All initial page loads in one subdirectory cause the VB compiler to run. Oddly, page loads in that directory's subdirectories do not cause the VB compiler to run.
There are no elements in the Web.config.
This happens in every solution that includes the project.
None of the Microsoft.VisualBasic assemblies are referenced in the project
Is there a setting somewhere that I can change that will disable VB compiler?
Could this be due to a referenced assembly used in this folder but nowhere else?
Since there seems to be some concern with the validity of this question, I and another senior developer have spent about 10 hours trying to run down this problem. We have searched the code base, visual studio, and online for an answer but it appears to be unique enough that no one has brought it up.
Additionally, when the same code is put in a different directory, the VB compiler does not run on initial page load. This is what leads me to believe there is a setting somewhere that I am missing.
Every time I've seen this, it's because of a "badly"-compiled file that exists in the folder structure (not even necessarily the csproj).
Check the folder structure of the pages in question, see if there's a bad file located somewhere in there. You may have to Show All Files in Visual Studio.
Delete it with extreme prejudice.
When running a web application project, at seemingly random times a page may fail with a CS0433 error: type exists in multiple DLL's. The DLL's are all generated DLL's residing in the "Temporary ASP.NET Files" directory.
Add the batch="false" attribute to the "compilation" element of the web.config file.
This problem occurs because of the way in which ASP.NET 2.0 uses the application references and the folder structure of the application to compile the application. If the batch property of the element in the web.config file for the application is set to true, ASP.NET 2.0 compiles each folder in the application into a separate assembly.
http://www.sellsbrothers.com/1995
http://support.microsoft.com/kb/919284
This might happen if you place .cs files in App_Code and changed their build action to compile in a Web Application Project.
Either have the build action for the .cs files in App_Code as Content or change the name of App_Code to something else. I changed the name since intellisense won't fix .cs files marked as content.
More info at http://vishaljoshi.blogspot.se/2009/07/appcode-folder-doesnt-work-with-web.html
One possible reason for this error is that there are 2 aspx pages which are having the same name in their inherits= in the <#page language=......inherits=> line.
Changing the inherits= name solves the error.
Just in case someone else shares my problem, I got this error when trying to publish a Web Site of a newly branched project, build worked perfectly.
Turns out I had forgotten to remove the checkbox for "Allow precompiled site to be updatable" under publish Settings -> Configure precompile.
As another data point, I just had this problem without any evidence of circular references as described in the links in Ben's answer. Building my web site project would fail with a few of these errors, and setting compilation batch="false" fixed it, but I didn't want to go that route as this is a large-ish production website.
This solution was in a subfolder of my D:\svn folder, which I had mapped to S:. When I opened the solution from S:, these errors occurred, but if I went straight to D:\svn and opened the solution, no errors.
I also noticed that, despite having compilation batch="true" in my web.config, when opening the solution from the mapped S: drive all my .ascx files get compiled into their own assemblies. If I open it from the physical location, the .ascx files get compiled into their respective folders' assemblies (which is how batch="true" is supposed to work).
Strange.
This error was due to conflict between class name of web form and wsdl stub(code behind file .cs) having the same class name i.e.
ASPX page: Dashboard
Class: partiacl class Dashboard
AppCode/APIServices.cs: public partial class Dashboard
Error was reproducible only on publishing the website but build and debug did not inform any error.
In my case deleting all output assemblies from bin folders in all projects in the solution solved the issue. Unfortunately I have no explanation for it.
In my case I had renamed a project, so also the dll had been renamed. When I just copied the new dll but didn't think of deleting the old one from the server, I soon had a bunch of pairs of classes with the same names. Deleting the outdated dll's was doing the trick (of cause).
None of these answers worked for me, however I did fix the problem. Since I was using VS's Publish function to deploy the web application, I selected the option to delete all existing files prior to publish in the Publish Web wizard. This forced a clean copy of the application and everything worked fine from there.
This solution might be helpful if your local debugging copy works fine but published system isn't. Also great if you don't want to take the time to track down individual dlls to delete and don't mind the production files being deleted first.
In my case, the problem was solved when I edited a Designer.cs file that still had the duplicated class name. for some reason, when i renamed the class "logout" to "logout2", in the designer file it was not automatically changed, and was still "logout", and this class name already existed in a precompiled dll in my project (that belongs to a third party web app that I work with and develop around of).
Got this problem when put a part of an aspx page into the separate user control. On my machine everything was fine, on the server got an error.
Renamed the problem class and file.
http://support.microsoft.com/kb/919284 Method 2: Reorder the folders in the application is writing about possible circular references
None of these solutions worked for me. Both of my conflicting DLLs were in C:\...\AppData\...\Temporary ASP.NET Files\...
The problem was that I had rolled back my source repo to an earlier version - before we moved a type from one project to another project within the same solution.
I tried deleting the newer DLL - which should not have even been there at all in the older codebase - from the "Temporary ASP.NET Files" location identified by msbuild. msbuild just put it back.
I also tried the web.config setting that some here have used successfully, but that did not work either. Although, as I write this, I realize that there were actually two MVC projects within the same solution and both had errors, so the problem may have been that I did not add the setting to both.
I tried rolling my source repo forward and cleaning and rolling back again and cleaning. Nothing.
I tried deleting everything the "Temporary ASP.NET Files" location. msbuild just put it back again.
Finally, I tried rebuilding in Visual Studio. Although the command line output and the "Errors" output both gave the same msbuild "Temporary ASP.NET Files" error, the Intellisense error - when hovering over the conflicted type - actually complained about DLLs in output directories. Apparently "Clean" and "Rebuild" were not doing their jobs. I manually deleted the DLLs in the output directories identified by Intellisense, and the problem was solved.
tl;dr - Make sure you're covering all of your web.configs with the batch setting, and try to leverage Intellisense for further clues.
My problem was linked to a .dll that was getting generated in my project folder.
If you are referencing another file, instead of doing everything you see above, what fixed my problem instantly was just deleting the .dll that was staying inside my /bin directory for my project.
The problem isn't necessarily a web.config fix - it's a circular reference that needs to get resolved. I realized that I cleared the old .dll in my original project file but not in the project that was referencing it.
I don't recommend making the modification to your web.config file because that's just a band-aid fix - not really addressing the actual problem. Do that if you don't feel like fixing the problem, but if you want to avoid future headaches, just remove the .dll from both places.
I had a partial class with the same name in two different projects.
I solved it by only leaving it in one project.
None of this solutions worked for me. Compiling in "Release" mode worked, but when I switched to "Debug" I got umpteen of this error Messages.
I don't understand why, but a simple restart of Visual Studio was my solution.
Sometimes it may help to remove the solution and create it again.
Since this use to happen when converted from VS2005 to vs2010 some references to framework 4.0 (after upgrading ) remains in the solution, even all projects are defined as 3.5.
Normally rebuilding the solution should clear these problems.
I had the same problem when I was compiling the application on a compiling server.
My controller had a simple static code, so I changed my ascx:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="controllerName.ascx.cs" Inherits="Controls.controllerName" %>
To
<%# Control Language="C#" AutoEventWireup="true" Src="controllerName.ascx.cs" Inherits="Controls.controllerName" %>
Also removed the partial keyword from the codebehind and added a namespace to the codebehind.
This:
using System;
using System.Web.UI;
/// <summary>
/// My controller
/// </summary>
public partial class controllerName: UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
To this:
using System;
using System.Web.UI;
namespace Controles
{
/// <summary>
/// My controller
/// </summary>
public class controllerName : UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
And that worked for me.
For me this happened when I had my PrecompiledWeb/Publish location set to the current directory which was where the site's root folder was too.
My Web Site was then seeing the publish folder as part of the project when compiling/building and then finding duplicates in that manner.
i.e. Don't put the published/precompiled version of your site in your site's code folders.
If the DLL's are showing in a temporary folder, you should try cleaning your solution.
Posting my solution:
The issue was related to the "On-Access Scan" of Mcafee Antivirus. Disabling this solved the problem. Somehow, the ASP Temporary folder was not being used properly by ASP when the antivirus was ON.
Hope this helps someone.
App_Code folder is causing the problem , put the class outside the folder (Works fine)
App_Code folder is not designed for Web Application Projects
http://vishaljoshi.blogspot.in/2009/07/appcode-folder-doesnt-work-with-web.html
Go to Add reference and search for both the dll,
Both of the dll would have checked, uncheck one of the dll, as there are references to the same dll with different version ambiguity gets generated.
My solution was to replace CodePage="...." with CodeBehind="..." in the .aspx file. Somehow it was left as CodePage during a migration from previous .NET versions.
This page directive creates another dll file which conflicts with the projects dll file.
I faced with the problem in compile time.
I agree with the batch="true" attributes, error is telling there exist 2 assembly
Solution 1: deleting one of them
Solution2: Configure one of them
Had a similar problem, In my case, I noticed, that cleaning a solution doesn't clear the bin folder in the visual studio. There was old compiled .dll present in the folder that is causing the issue.
Solutions:
Manually delete bin folder and recompile
In case of publish, select delete existing files prior to publish.
This will solve the issue.
You should define an alias for one of your references.
In your project file .csproj add the following item:
<ItemGroup>
<Reference Include="temp1.dll">
<Aliases>MyAssembly</Aliases>
</Reference>
</ItemGroup>
After adding the above ItemGroup, MyAssembly will represent a root namespace that will contain all namespaces in the assembly temp1.dll.
Then you can have access to the type foo, which is located in temp1.dll, as follow:
using MyAssembly.foo;
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 am working on a C# application which I have divided it to few projects. Recently when the solution becomes larger, I get different errors such as MissingMethodException or even worse, DLL not found messages.
The only solution is to delete my bin folder and build the project again.
I wonder if this is a common problem with visual studio or might be I am doing something wrong?
UPDATE:
I am working on a winforms soloution, while one project is the form and other projects are user control, data models and etc.
I do reference the needed project in other projects using the visual studio's add reference option.
UPDATE 2
I am suspecting when I have a new .cs file to extend a class using partial keyword in any projects this happens!!!! I am 99% sure, I am going to check some more times to see of this is really the case!
It's not really a common problem but messy things can happen some times on visual studio.
What I would do is to check the settings and dependencies of every project and check things like they build in the correct order, platform, output path, etc. In our case, some times when the solution travels to many developers/computer settings can alter.
Also another thing you could do would be to copy the main project to a new solution and add the rest of the projects. This has worked form me in a similar situation.
I hope I gave you some ideas.
When I re/build my ASP.NET website I do not receive any errors.
However when I PUBLISH the site, it gives me a 'Circular file references are not allowed.' error.
I read a little on the web about this, and it provided a batch='false' option, which I tried and does nothing.
The page, has a master page, which may call on the same control twice; however, this control does not refer back to anything
TY - Theo
Theo, I also received this error quite a few times which is very annoying, even though I searched for ages for circular file references I couldn't find any. In the end I decided that although there are no definite circular file references, the compiler did not like it when I referenced a control in a parent folder e.g. I have a control in the folder /UserControls/Panels/ManagerPanels/ which references a control in the folder /UserControls/Panels/. This works ok when coding but trying to publish or debug brought about the Circular file reference problem. Sorry to say the only solution I found was to move the referencing control back a folder into the same folder as the control it was referencing, this fixed the problem (although it is extremely frustrating as I like a nice folder structure for my controls, of which there are many). Hope this helps
The reason that batch=false won't fix anything is publishing a website precompiles it so the batch attribute is irrelevant.
You can get more details on the error by using the aspnet_compiler command. I think this only works if you've hosted your website locally in IIS.
aspnet_compiler -v /
The above command would precompile your website locally if it's running on port 80 and show you where the problems are.
If you have Project A and Project B in the same solution, and you add a reference from Project A to Project B and also a reference from Project B to Project A then you’ll get this error. References work like a parent\child relationship so a project cannot be both the parent and the child of another project.
You’ll need to work out where the circular reference is and maybe move some code around, or even create a new project in order to resolve it.
if you add multiple project, one project depend another one project means check your reference. if u gave circular form means that error will come
There actually was a circular refernce in my case. As correctly highlighted by Doug Domeny, and Starjumper. My folder structures were:
UI > Templates > Header.ascx
Login.ascx
About.aspx
Inside Header.ascx we were using Login.ascx, the Header.ascx was then being used inside About.aspx and since for each folder there is a DLL, it became circular. I feel the error message could have been more elaborate.
To resolve, I created a copy of Login.ascx inside UI > Template folder and renamed it to Login1.ascx, and started using Login1.ascx inside Header.ascx