The situation:
I have a class library, called RT.Servers, containing a few resources (of type byte[], but I don't think that's important)
The same class library contains a method which returns one of those resources
I have a simple program (with a reference to that library) that only calls that single method
I get a MissingManifestResourceException with the following message:
Could not find any resources
appropriate for the specified culture
or the neutral culture. Make sure
"Servers.Resources.resources" was
correctly embedded or linked into
assembly "RT.Servers" at compile time,
or that all the satellite assemblies
required are loadable and fully
signed.
I have never played around with cultures, or with assembly signing, so I don't know what's going on here. Also, this works in another project which uses the same library. Any ideas?
All I needed to do to fix this problem was to right-click the Resources.resx file in the Solution Explorer and click Run Custom Tool. This re-generates the auto-generated Resources.Designer.cs file.
If the .resx file was added to the project manually, the Custom Tool property of the file must be set to "ResXFileCodeGenerator".
The problem is due to a mismatch of namespaces, which occurs if you change the "default namespace" of the assembly in the project settings. (I changed it from (previously) "Servers" to (now) "RT.Servers".)
In the auto-generated code in Resources.Designer.cs, there is the following code:
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Servers.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
The literal string "Servers.Resources" had to be changed to "RT.Servers.Resources". I did this manually, but running the custom tool would have equally well done it.
I just came across this problem today, and I found this Microsoft Help and Support page that actually did work around the problem.
I had a couple delegates at the top of my file, in the global namespace, and all of a sudden I was getting a MissingManifestResourceException when running the program, on this line:
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
Then I moved the delegates into the namespace, got the same error. Finally I put the delegates in the only class in that file, and the error went away, but I didn't want the delegates in that class or namespace.
Then I came across that link above, which said
To resolve this problem, move all of the other class definitions so that they appear after the form's class definition.
I put the delegates (which I would not consider "class definitions") at the bottom of that file, outside of the local namespace, and the program didn't get the MissingManifestResourceException anymore. What an irritating error. But, that seems like a more robust solution than modifying the auto-generated code :)
I've run into a similar issue and, although I know it isn't the cause the OP had, I'll post it here so that if someone else runs across this problem in the future, an answer will be available.
If you add a class before the designer class you will get a MissingManifestResourceException exception at runtime (no compile time error or warning) because
Visual Studio requires that designers use the first class in the file.
For (slightly) more information see this post.
I had the same problem, but using the Run Custom Tool command as suggested by Timwi did not help in my case.
However it lead me into the right direction, because I ended up in the Properties of the .resx file. Here I noticed a difference to another .resx file that caused no problems.
In my case I had to change the property "Build Action" from "Resource" to "Embedded Resource".
My best guess for the reason is, that I had the .resx in a library that was used from another application. My application did not have its own .resx file, so it had to use the one from the library - which is only available when it's embedded in the library and not "stand alone".
When I run in a similar issue, in Vs 2012, it turned out that the "Custom Tool Namespace" property of the resx file was wrong (in my case, actually, it was unset, so the generated code yeld this exception at runtime).
My final set of properties for the resx file was something like this:
Build action: Embedded Resource
Copy to Output Directory: Do not copy
Custom Tool: ResXFileCodeGenerator
Custom Tool Namespace: My.Project.S.Proper.Namespace
I ran into a different cause of this problem, which was unrelated to resx files. I had a class library where AssemblyInfo.cs contained the following:
[assembly: ThemeInfo(
ResourceDictionaryLocation.SourceAssembly,
ResourceDictionaryLocation.SourceAssembly)]
The assembly did not contain any WPF code, theme or Resource dictionaries. I got rid of the exception by removing the ThemeInfo attribute.
I did not get an actual exception, only
A first chance exception of type 'System.Resources.MissingManifestResourceException'.
Viewing exception details, the system was requesting MyAssembly.g.resources
Hope this might be of help to someone else.
Also see: MissingManifestResourceException when running tests after building with MSBuild (.mresource has path in manifest)
I repeat the answer here just for completeness:
It appears adding LogicalName to the project file fixes it:
<LogicalName>$(RootNamespace).Properties.Resources.resources</LogicalName>
i.e. so the embedded resource entry in the project file looks like this:
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<LogicalName>$(RootNamespace).Properties.Resources.resources</LogicalName>
</EmbeddedResource>
</ItemGroup>
This is detailed in: http://blogs.msdn.com/b/msbuild/archive/2007/10/19/manifest-resource-names-changed-for-resources-files.aspx
Note that we are using a .resx file, but the bug still appears to occur.
Update: The problem with resources (incl. XAML) appears to be related to output paths and the use of forward or backward slashes as detailed in:
Why does modifying project output directories cause: IOException was unhandled "Cannot locate resource 'app.xaml'."
Not sure it will help people but this one worked for me :
So the issue I had was that I was getting the following message:
Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "My.Resources.Resources.resources" was correctly embedded or linked into assembly "X" at compile time, or that all the satellite assemblies required are loadable and fully signed"
I was trying to get the resources that were embedded in my project from another class library.
What I did to fix the problem was to set the Access Modifier in the tab Project->Properties->Resources from "Internal" (accessible only within the same class library) to "Public" (accessible from another class library)
Then run and voilà, no more error for me...
The solution given by BlaM worked for me too.
I am a VS 2013 User. After going through many fixes but no luck, I tried this:
Right-click the resource file, one-by-one, in case of multiple-files.
Make sure, the property "Build Action" is set to "Embedded Resource".
That's it! :)
I had the same issue, but in my case i places a class in a usercontrol which is related to the usercontrol like this
Public Class MyUserControlObject
end Class
Public Class MyUserCOntrol
end Class
The solution was to move the MyUserControlObject to the end of the Usercontrol class, like this
Public Class MyUserCOntrol
end Class
Public Class MyUserControlObject
end Class
I hope this helps
I was getting the MissingManifestResourceException error after I ported my project from VS2005 to VS2010. I didn't have any other classes defined in the file that contains my Form class. And I also had my resx Resource File Name set correctly. Didn't work.
So I deleted the resx files and regenerated them. All good now.
Recently ran into the same problem, struggled for a bit, found this topic but no answers were correct for me.
My issue was that when I removed main window from my WPF project (it does not have a main window), I forgot to remove StartupUri from App.xaml. I guess this exception can happen if you have a mistake in StartupUri, so in case if anybody is struggling with this - check your StartupUri in App.xaml.
Recently stumbled upon this issue, in my case I did a few things:
Make sure the namespaces are consistent in the Designer.cs file of the resx file
Make sure the default namespace of the Assembly(right click the project and choose Properties) is set the same to the namespace the resources file is in.
Once I did step 2, the exception went away.
I had this problem when I added another class in the file just before the class which derived from Form. Adding it after fixed the problem.
Also the same error may occur when you put a new class into the source code of a designer created form's class.
This new class may be removed, and placed in a different cs file.
(At least in my case this was the problem...)
Because I am pre-compiling my web application (using VS2012 publish feature). I was getting the error above. I tried all the suggestions, but weirdly changing 'Build Action' to 'Content' did the trick!
In my case, I have a web api with resources and I create a nuget package from that. When I use this nuget in other projects, I realise that when I request a api with resources, I am getting MissingManifestResourceException after a bit reasearch, I learn nuget packager is not packing resources automatically. If you want to use resources files, you have to do that manually. So you need to add below lines to your .nuspec file:
(Visit https://github.com/NuGet/Home/issues/1482)
<package>
<metadata>
</metadata>
<files>
<file src="bin\Debug\en\MyAssembly.resource.dll" target="lib\net40\en\MyAssembly.resource.dll" />
<file src="bin\Debug\es\MyAssembly.resource.dll" target="lib\net40\es\MyAssembly.resource.dll" />
</files>
</package>
But, before adding files, you need to be sure which version of .net you are using.
I had the with a newly created F# project.
The solution was to uncheck "Use standard resource names" in the project properties -> Application -> Resources / Specify how application resources will be managed.
If you do not see the checkbox then update your Visual Studio! I have 15.6.7 installed. In 15.3.2 this checkbox is not there.
Just to mention. If you use a constant or literal, make sure it refers to a resource of the form ProjectName.Resources, and does not cpntain Resources.resx.
It could save you an hour or two .
I've encountered this issue with managed C++ project based on WinForms after renaming global namespace (not manually, but with Rename tool of VS2017).
The solution is simple, but isn't mentioned elsewhere.
You have to change RootNamespace entry in vcxproj-file to match the C++ namespace.
In my case it was a typo in the Xaml of a window opened from Winforms Form:
Incorrect: <Image Source="/Resources/WorkGreen.gif"/>
Correct: <Image Source="../Resources/WorkGreen.gif"/>
It may help someone
In my case I have changed my project namespace and hence my solution was throwing "missingmanifestresourceexception" exception. Instead of right clicking the .resx file in the solution explorer and clicking on "Run Custom Tool" option, I have replaced the
rootnamespace to new namespace in .csproj file(RootNamespace) and rebuilded the solution again. All Resources.Designer.cs files namespaces got automatically changed with new namespace.
I hope my answer will help someone.
If you're getting this while generating a C# project using CMake, the solution I found may help you.
Your CMakeLists.txt file needs
set_property(TARGET yourTargetName PROPERTY VS_GLOBAL_RootNamespace yourRootNamespace)
Substitute your own values for yourTargetName and yourRootNamespace, obviously.
Then the resources will get embedded in your assembly!
One more reason to get this error is- '.resx' file excluded from project.
In my case, '.resx' file was excluded from project.
Select 'show all files' option in solution explorer.
Right click on '.resx' file(s) and click include in project.
Rebuild the project/solution.
I read all the answers and nothing worked for me. Most likely my situation is different, but same error. My issue was that I had two projects. Second project had a lot of forms added to it from the first one as "Add as link".
For WinForms, there are 3 required files: the code, the designer, and the resource files. If you add all 3 files at the same time as "Add as link", Visual Studio does not link them together as same form. It will compile, and run, but it will blow up with the same MissingManifestResourceException error.
Fix: You have to do them individually, in order: code file --> designer file --> resource file. Then they are grouped and no more error, at least for me.
From the Microsoft support page:
This problem occurs if you use a localized resource that exists in a satellite assembly that you created by using a .resources file that has an inappropriate file name. This problem typically occurs if you manually create a satellite assembly.
To work around this problem, specify the file name of the .resources file when you run Resgen.exe. While you specify the file name of the .resources file, make sure that the file name starts with the namespace name of your application. For example, run the following command at the Microsoft Visual Studio .NET command prompt to create a .resources file that has the namespace name of your application at the beginning of the file name:
Resgen strings.CultureIdentifier.resx
MyApp.strings.CultureIdentifier.resources
Related
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 have stumbled into an issue that is really annoying.
When I debug my software, everything runs OK, but if I hit a breakpoint and edit the code, when I try to continue running I get an error:
Metadata file 'XYZ' could not be found
After looking around for a while, I found some a similar issues, but they were all regarding a build failure, which is not my case (this happens only after edit-continue).
What I have tried so far:
My code is compiling and running.
I cleaned the solution and restarted VS.
I made sure that the missing file's project is being build for the configuration I am running (in configuration manager).
I manually built the missing file's project.
Some extra info:
It does not matter what I change, still get the same error (the change is not related to the missing file).
This happens also when I pause and continue (not only breakpoints)
I am running the project using a custom configuration (configuration manager...). When I run it using the default Debug configuration the error does not occur.
Any ideas?
Eventually what solved the issue was:
Clean every project individually (Right click> Clean).
Rebuild every project individually (Right click> Rebuild).
Rebuild the startup project.
I guess for some reason, just cleaning the solution had a different effect than specifically cleaning every project individually.
Edit:
As per #maplemale comment, It seems that sometimes removing and re-adding each reference is also required.
Update 2019:
This question got a lot of traffic in the past, but it seems that since VS 2017 was released, it got much less attention.
So another suggestion would be - Update to a newer version of VS (>= 2017) and among other new features this issue will also be solved
As far as I can tell, this happens when the project dependencies gets messed up for whatever reason (whilst all the inter-project references are still intact). For many cases, it is NOT a code issue. And for those who have more than a few projects, going through them one at a time is NOT acceptable.
It's easy to reset project dependencies -
Select all projects and right click unload
Select all projects and right click reload
Rebuild solution
For those who have an issue in their code or some other issue that's causing this problem you'll obviously have to solve that issue first.
One possible reason could be you have upgraded the some of your projects (in the solution) to higher version e.g. from .NET 4.0 to 4.5 This happened in my case when I opened the solution in VS 2013 (originally created using VS 2010 and .NET 4.0). When I opened in VS 2013 my C++ project got updated to .NET 4.5 and I started to see the problem.
Generally this kind of error comes with human mistakes like if we change the namespace in some improper way, or changing folder names from explorer for current project etc, where compiler is unable to detect sometimes.
I came across the same error, to resolve which I tried few steps. Please follow all the steps :
Clean whole Solution
Right Click on every Project in your solution , Go to Properties and make your Default namespace as well as Default assembly name same as in your code (i.e namespace before class name)
Check Folder names for each project by going through the explorer(Where your project solution is). If not matching with your project names, make it similar (Like step 2) to them.
Remove all your references from each project relevant to another of same solution, and add it again.
In Your Project Solution folder, you will find Visual c# Project file. Right click and open with Notepad. In your initial lines you would find for lines for every project like below:
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "**Client**", "**Client** \ **Client**.csproj", "{4503E259-0E3B-414A-9074-F251684322A5}"
EndProject
Check again Foldernames (I have highlighted in BOLD) and make it similar to what you did in step 2.
Clean the whole solution again
Build The Solution (If doesn't work try building individual after cleaning again)
Make sure all your dependent projects are using the same .Net Framework version. I had the same issue caused by a dependent project using 4.5.1, while all others were using 4.5. Changing the project from 4.5.1 to 4.5 and rebuilding my solution fixed this issue for me.
XYZ couldn't be found because is not built yet....
Right click on the solution and check Project Dependencies, the Project Build Order should also change according to the dependencies that have been set.
The only thing that worked for me was to delete the Solution User Options (.suo) file. Note that, this is a hidden file.
To locate this file, close your Virsual studio and search for .suo from the file explorer within your project.
PS: a new .suo file will be created again when you rebuild your project and hopefully this newly created one wont give you issues.
I hope that helps someone get rid of this anoying error :).
I had this problem for days! I tried all the stuff above, but the problem kept coming back. When this message is shown it can have the meaning of "one or more projects in your solution did not compile cleanly" thus the metadata for the file was never written. But in my case, I didn't see any of the other compiler errors!!! I kept working at trying to compile each solution manually, and only after getting VS2012 to actually reveal some compiler errors I hadn't seen previously, this problem vanished.
I fooled around with build orders, no build orders, referencing debug dlls (which were manually compiled)... NOTHING seemed to work, until I found these errors which did not show up when compiling the entire solution!!!!
Sometimes, it seems, when compiling, that the compiler will exit on some errors... I've seen this in the past where after fixing issues, subsequent compiles show NEW errors. I don't know why it happens and it's somewhat rare for me to have these issues. However, when you do have them like this, it's a real pain in trying to find out what's going on. Good Luck!
Well, my answer is not just the summary of all the solutions, but it offers more than that.
Section (1):
In general solutions:
I had 4 errors of this kind (‘metadata file could not be found’) along with 1 error saying 'Source File Could Not Be Opened (‘Unspecified error ‘)'.
I tried to get rid of ‘metadata file could not be found’ error. For that, I read many posts, blogs etc and found these solutions may be effective (summarizing them over here):
Restart VS and try building again.
Go to 'Solution Explorer'. Right click on Solution. Go to Properties. Go to 'Configuration Manager'. Check if the checkboxes under 'Build' are checked or not. If any or all of them are unchecked, then check them and try building again.
If the above solution(s) do not work, then follow sequence mentioned in step 2 above, and even if all the checkboxes are checked, uncheck them, check again and try to build again.
Build Order and Project Dependencies:
Go to 'Solution Explorer'. Right click on Solution. Go to 'Project Dependencies...'. You will see 2 tabs: 'Dependencies' and 'Build Order'. This build order is the one in which solution builds. Check the project dependencies and the build order to verify if some project (say 'project1') which is dependent on other (say 'project2') is trying to build before that one (project2). This might be the cause for the error.
Check the path of the missing .dll:
Check the path of the missing .dll. If the path contains space or any other invalid path character, remove it and try building again.
If this is the cause, then adjust the build order.
Are you using a database code generation tool like SQLMETAL in your project?
If so, you may be facing a pluralized to unpluralized transition issue.
In my case, I have noted that some old pluralized (*) table names (upon which SQLMETAL adds, by default, an "s" letter at the end) table references to classes generated by SQLMETAL.
Since, I have recently disabled Pluralization of names, after regerating some database related classes, some of them lost their "s" prefix. Therefore, all references to affected table classes became invalid. For this reason, I have several compilation errors like the following:
'xxxx' does not contain a definition for 'TableNames' and no extension method 'TableNames' accepting a first argument of type 'yyyy' could be found (are you missing a using directive or an assembly reference?)
As you know, I takes only on error to prevent an assembly from compiling. And that is the missing assemply is linkable to dependent assemblies, causing the original "Metadata file 'XYZ' could not be found"
After fixing affected class tables references manually to their current names (unpluralized), I was finnaly able to get my project back to life!
(*) If option Visual Studio > Tools menu > Options > Database Tools > O/R Designer > Pluralization of names is enabled, some SQLMETALl code generator will add an "s" letter at the end of some generated table classes, although table has no "s" suffix on target database. For further information, please refer to http://msdn.microsoft.com/en-us/library/bb386987(v=vs.110).aspx
Hope it helps!
I had this error come up. I followed all of the solutions here but nothing worked. I was using Visual Studio 2013 Professional. I couldn't get the individual project rebuilds to work and I finally figured out there was a circular dependency in my references. Visual Studio does a pretty good job normally of warning you if you are adding a reference to something that references back, but for some reason it didn't in this instance. I added a reference to a project that referenced the project I was working on - and it accepted it. VS bug perhaps?
My 5 cents.
This problem started after a solution wide clean.
I managed to get the problem to go away by setting the Active Solution configuration in: Build -> Configuration manager to release. Then build and set it back to debug again. The build succeeded after that.
Close VS, locate and remove the 'packages' folder from outside of visual studio. Restart VS and build -> all dependencies are reinstalled
Visual Studio 2019 Community 16.3.10
I had similar issue with Release build. Debug build was compiling without any issues.
Turns out that the problem was caused by OneDrive. Most likely one could experience similar issues with any backed-up drive or cloud service.
I cleaned everything as per Avi Turner's great answer.
In addition, I manually deleted the \obj\Release -folder from my OneDrive folder and also logged to OneDrive with a browser and deleted the folder there also to prevent OneDrive from loading the cloud version back when compiling.
After that rebuilt and everything worked as should.
this happens because of the difference of names in the folder name and namespace name. If u create a namespace in a certain name , and later you rename it the namespace will have the old name itself. And the compilation will take the old path to find the .dll and .exe file . To avoid this open the .csproj file of each namespace with a text file , and find the old path in the file.
remove this, clean and rebuild the solution. This worked for me. I spent an entire day working on this problem.
I had this and managed to fix it using this SO answer:
Metadata file '.dll' could not be found
I had to uncheck all of the boxes, click Apply, reenable all of the checkboxes and then click apply again, but it fixed the problem.
I just ran into this issue and after an hour of screwing around realized I had added an aspx file to my product that had the same name as one of my Linq-To-Sql classes.
Class and Page where "Queue".
Changed the page to QueueMgr.aspx and everything built just fine.
For a new build, it could be that some dependencies aren't installed. For me it was Crystal Reports.
It happens when one project dll is failing and that is referenced by number of projects. So first fix it and then Build individuals.
I ve had this problem and it has started after importing our solution to TFS as a new project.I came across this topic and found a quick solution with some inspiration from your answers.
All i needed to do is to rebuild the project thats supposedly lost its metadata file and voila , problem solved.
There's also one another silly reason which you should check with patience... as it occurred to me after wasting 4hours searching for answers:
The story to me was that I accidentally changed a small line of code among thousands of c# class files and then trying to rebuild the solution. As you could imagine, I ended up with 40+ meta data file missing errors and with 1 compilation error among them -- which I didn't check carefully, purely thinking all errors were the same!
after 4 hours searching and then accidentally double checking my error list, I found that silly code error, fixed it, compiled, and then error disappeared.
Not a good answer to your problem, but do hope my case wasn't same to yours.
I had the same problem. In my case I had by mistake I had set all the projects apart from the project with the main method as console application.
To resolve I went to every project other than the one with main function and right click> properites > output type > class library
it was happened to me because I've a strange clash in the namespaces:
I had
AssemblyA
with namespace
AssemblyA.ParentNamespace
witch defines ClassA
and in the same assembly another namespace with name
AssemblyA.ParentNamespace.ChildNamespace
witch defines a different ClassA (but with the same name)
I had then in AssemblyA.ParentNamespace IInterfaceB witch had a method that in the beginning returns IEnumerable and a ClassB witch implements IInterfaceB
I had later modified the method in ClassB to return IEnumerable but I've forgot to update the IInterfaceB definition, so the method there was still returning IEnumerable
the fun fact was that the solution still complile if I did a rebuild all, but the tests witch refers AssemblyA didsn't work and returns the "Metadata file could not be found"error.
updating InterfaceB to correctly return IEnumerable as its implementor ClassB did solved the problem, unfortunately the error message was vague and also the fact that the compilation worked makes me suppose that maybe there is something to fix in the compiler
A coworker was running into this problem and the cause was eluding us. Eventually we realized that the project directory (and therefore the path to the NuGet packages) contained %20 (thanks, some Git gui tool which shall not be named) and the error messages showed that the compiler was looking for an very similar-looking path but one which had to %20, rather a space. Apparently something in the build system somewhere performs HTML-decoding on local filesystem paths.
Renamed the working copy directory and everything started working.
I had this issue too.
It started after I did a little folder tidying in my project.
I then tried to compile and got many duplicate class errors. (despite them not being duplicated. I think the linking was just out of wack)
Upon checking these, the errors would all disappear leaving only the "Metadata file ...debug\application.exe could not be found" error.
I solved this by looking in the build output window to find which classes were duplicated.
I would then right click the class name and "go to definition".
there will be two definitions to select from, open them both, the second definition will seem to open the same file again, however the second one will identify as the error source(red underline).
Delete all the code out of the file and save(This will not effect your actual file).
This should now compile correctly.
Ensure that there are no spaces in the path to your project...
I am using Windows 10 with Visual Studio Community 2019 and I was cloning a multi project solution as it was from a GIT repo. I was having this error with all other dependencies in the solution along with a E_POINTER error. Its path, inherited from GIT, had spaces like C:/repos/MY PROJECT NAME/ ...
I deleted it, cloned it again and make sure that its path contained no spaces like C:/repos/MY_PROJECT_NAME/ ...
That fixed my problem.
I had same issue too.
In my case, I recently add an internal class to somewhere in project. One of the dependencies in solution has same class name and both of them are added correctly to references.
I changed my last activity and rebuild, it works.
Be sure that your compiler messages are valid. In my case I catch reference error from there, not listed as an error in Error List.
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
For some reason on my current project I create my resource file via the project properties, add a load of existing images. Then go to add these images to menu items, save it. At this point everything looks fine and the images are all mapped correctly.
However once I close the designer for that form, then open it up I get the error dialog saying:
The type 'My.Project.Properties.Resources' has no property named 'icon_plus'.
The annoying thing is that if you follow it through to the code there is no error, it compiles fine:
this.newToolStripMenuItem.Image = global::My.Project.Properties.Resources.icon_plus;
I have tried deleting all resources and removing the resource file from the project, completely closing down the IDE then re-loading it. I have moved the location of the files, but I am just out of ideas and it is REALLY starting to grate with about 10 forms and controls which each give me this error them remove the icons from the UI.
Take a look at project references, and remove the reference to self.
This is one of those VERY annoying issues, which I would never have thought about until I got another issue which caused me to change things.
It seems to have been down to the application using the Client Profile for .net 4 rather than just the default .net 4 runtimes. Once I changed this over this issue stopped and my other missing namespace issue which recently arose went away.
Here's what worked for me. (Tried everything posted and no joy.)
When I first started the projects the default namespace specified in the projects properties was MyProject. (so most of my classes looked like namespace MyProject{ public class foo{} }
Later I changed the namespace for my classes from MyProject to CompanyName.MyProject
This is also when the problem occurred.
In my case, I had to go back to the Project Properties and change the actually entry
in Default namespace to CompanyName.MyProject
Bang, no more problem.
Its most likely to do with a Namespace conflict.
Double check all namespaces in the project, VS likes to do 'ProjectName.FolderName'. If it auto-changes one of the classes/resource files in your Icon folder to ProjectName.Icon, it may conflict with a class/struct name.
Funny thing is that the application builds..
I ran across the same issue. VS wouldn't load any of the form objects. I tried all of the other approaches with no outcome.
Previously I changed all of the Private global variables to Public properties.
public Textbox exampleTextBox { get; set; }
I did this for multiple reasons, but the designer view doesn't like it. I believe it must have some parsing issues.
the object must be a global variable not a property.
public Textbox exampleTextBox;
This fixed my designer view.
I have found another way
Move initialization form code in private methode like below
private void FormInitialize(){/*Your code here*/}
In form constructor use it like this
public Form1()
{
InitializeComponent();
FormInitialize();
}
And from Button, menuItem or other call methode like this
private void ChangeCultureToFrench_Click(object sender, EventArgs e)
{
Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr");
this.Controls.Clear();
this.InitializeComponent();
FormInitialize();
}
I hope this help ;-)
I have come accross this error before. It arose for me when I added a resource, and then took it away or ammended it. The only way I found I could get around this problem was by opening up the .csproj file and looking for the .ico that it is giving the error for and removing it. Your looking for
<ItemGroup>
<None Include="Resources\SomeResource.ico" />
</ItemGroup>
After this, save the file. Open the solution and re-add. Hopefully this will work for you. Note however, this is not the ideal solution.
Edit:
OK. So this did not solve your problem. Go into the solution folder and navigate to the 'Properties' folder. inside you will see a file called resources. Open it and try to find your problematic file name
<data name="YourNamedIco" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\SomeResource.ico;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
if you do find it, remove this, save.
I hope this helps.
I had the same issue as you, though the "solution" I used may not even be called as such. I did know I add a few setup projects to it, and removed it, alongside fiddling with the build actions of a few images.
The solution I used? Delete the current project, and revert to the most recent made backup, which did not have the issue. Of course, this would only work if you make backups of your project solutions.
If you do make backups of your project solutions, only try this method as a last resort.
I tried all the other answers by none of them worked.
What finally just seemed to work for me was doing "Unload Project" by right clicking on your project, then "Reload Project". Before checking if my .cs [Design] worked yet, I then also renamed my project to something else by right clicking the project in the Solution Explorer then clicking "rename".
Don't ask me why this worked...
Open Resources.resx file and add new image and then build your solution/project. Error will disappear.
Specifically the error occurs in the Resources.Designer.cs:
Error 2 The namespace 'ModulusFE' already contains a definition for 'StockChartX' Resources.Designer.cs 11 21 ModulusFE.StockChartX
I've googled this and am still quite confused. Does anyone know anything I might try?
I have tried rebuilding and cleaning, as well as renaming the Resources.Designer.cs file in hopes that it would rebuild, but no luck.
The top of the code says this:
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.225
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
Any ideas whatsoever would be appreciated.
Looks like a bug in VS code's OmniSharp.
Solution for me was to execute command "Restart OmniSharp".
Just do:
- ctr shift P
- type "Restart OmniSharp" .. hit enter
This fixed it for me.
I had this happen to me about a year ago and I don't remember exactly what the root cause was, but there are two things you might try:
If it's an auto-generated file (as 'Resources.Designer.cs' tend to be), try deleting it and letting VS re-generate it.
Either separately or in conjunction with #1, select Show All Files in the Solution Explorer or open the solution folder in Windows Explorer - it could be that a version of the file somehow got excluded from the project and is therefor 'invisible' to VS but still makes it angry...
I've had this problem, too, and it was because I created a new namespace, but the parent namespace contained a class with the same name.
This is an old question but I didn't find the fix I used, so I've added it here.
In my case it was a namespace with the same name as a class in the parent namespace.
To find this, I used the object browser and searched for the name of the item that was already defined.
If it won't let you do this while you still have the error then temporarily change the name of the item it is complaining about and then find the offending item.
Unfortunately, none of the other answers helped.
My problem specifically occurred in a WPF project.
The problem arose when I created a folder under the MainWindow folder, which effectively created a namespace something like ProjectName.MainWindow.Folder.
Now, I believe because of some static designer code, Visual studio gets confused between the class MainWindow and the namespace Project.MainWindow.Folder .
As a solution, I moved the Folder out of MainWindow. Looking at the Class View or the solution/project helps to recognize what namespaces and classes within them exist.
This just happened to me. What happened was that I duplicated a project that was originally under source control. Although I properly renamed everything, the file permissions on all the files were still set to read-only. When I started modifying some form controls, Visual Studio automatically created a Resource1 file because the original Resource file was read-only.
What I did to fix this was as follows:
allow write permissions on the project files.
deleted the original Resource file
Ctrl-A for all form elements, then Ctrl-X to cut them.
Save the form.
Ctrl-V to paste them all back.
Save the form.
I had to do this because the auto-generated code wasn't updating on it's own, so I "forced" it to update by making a change to the form. Not doing this left a bunch of code from form elements that no longer existed prior to changing the file permissions.
I had an xaml file with the following definition
<Window x:Class="mm2.Views"
.etc..
/>
mm2.Views was the name of a namespace in my app.
To fix it, I correctly renamed the xaml object:
<Window x:Class="mm2.Views.RecordedTracks"
.etc..
/>
I had a similar problem and resolved it by removing any copies/backups of the .cs file from the directory.
I had this same problem and it was due to naming a function in the code behind the same as my tool. Simple mistake but something to keep in mind as well.
I had a similar issue however found a different solution than what I have read. I came to my fix after reading P Walker's answer.
My issue happened when I named my resource file for Japanese language incorrectly. Long story short I was trying to create a Resource for Japanese but I accidentally named it localized.jp.resx. I then realized that the iso language code is ja not jp for Japanese. Once I changed the file name to localized.ja.resx and deleted everything that was in the designer file it fixed my problem.
This is what fixed my problem hopefully it helps someone else.
I came across a similar problem. After generating my database from an edmx file, I clicked 'save all' and 'build' and all the Types/Model classes that I created showed up in the error box. I researched why this happened and like your replies suggest, I thought it was something that was auto-generated.
However, solutions like deleting the auto-generated classes and re-generating them didn't work for me.
I eventually ran out of patience and decided I'd fix it another way. Since my script was saved, I just deleted the edmx file (and its reference in the web.config) and went back and created another one using "model from database" and didn't touch it after that.
Needless to say, I was pretty mad that it turned out like that.
Me too got this error,
When I change my WPF project's Target Framework to Framework Version 4.0 Client Profile -> Framework 4.0. It's solved by itself.
The way I solved it was to remove all of the enums from the model browser, and then re-add them again. Somehow miraculously the tool regenerated everything perfectly and the error message went away (I'm using VS2012, FYI).
What helped me many times, was just turning it off and on again..
Ctrp + shift + P -> Reload window in VS Code
Close and open the project/window.
Cleaning all bin, obj contents (in power shell)
Get-ChildItem .\ -include bin,obj -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse }
After this, it can be that I am missing something else, like some package reference or include, but usually it is, that underlying parser/compiler (omnisharp) just gets messed up and needs some restart to work properly again.
This may be a bit of an edge case, but we've run across this in our development environment from time to time. We had to setup a custom culture in Windows to support en-HK. Windows 8.1 now supports this culture natively as does Windows 2012 R2, but older machines need to have the culture created. Any machine that does not have this culture setup will get this error reported. The solution is to create the culture on the machine (We have a console app created for this purpose) and everything starts working again.
I had the same issue just now, and I found it to be one of the simplest of oversights. I was building classes, copying and pasting code from one class file to the others. When I changed the name of the class in, say Class2, for example, there was a dropdown next to the class name asking if I wanted to change all references to Class2, which, when I selected 'yes', it in turn changed Class1's name to Class2.
Like I said, this is a very simple oversight that had me scratching my head for a short while, but double check your other files, especially the source file you copied from to ensure that VS didn't change the name on you, behind the scenes.
If you are using different aspx.cs files that define classes of the same name you can use
<compilation targetFramework="4.5" />
under <system.web> in your web.config file.
Although I would still strongly advise that you would change the class name.
This is not the best solve, but if you really don't care it is an easy solution.
I simply renamed my class. So I had class Card and I changed it to MyCard.
I think this issue is because you have added for a single table, 2 DAL classes.
If this table is included in a relation, then remove the table_name.dbml for it, and keep that for the related tables.
You must use one of them.
I had a similar problem (Universal project, Visual Studio 2015), I solved it with the following changes:
In App.xml.cs was (it was ok):
namespace Test.Main {
Wrong, old version of App.xml:
x:Class="Test.Main"
Good, new version of App.xml:
x:Class="Test.Main.App"
I had something similar to this happen in my WPF application. It arose when I was trying to do some cleanup by declaring a namespace that was more descriptive. The problem arose because I had named the namespace in the code-behind (or cs) the same as the Window class. The namespace in the code-behind should have the last section stripped (after the rightmost dot) and used to declare the class and instantiate it. Notice Win below:
xaml
<Window x:Class="FrameApp.UI.Invoice.Win" ...>
code-behind
namespace FrameApp.UI.Invoice
{
public partial class Win : Window
{
public Win()
}
}
An obvious oversight but it set me back at least an hour with all the errors that appeared.
I had this issue, but mine was slightly different to the issues mentioned here. I was cleaning up my project and moving around some classes into new folders. I had a 'AddFilter' class that I moved into an 'AddFilter' folder - so I had actually wound up with a class that was sharing the name of a namespace. This was a bit tricky to spot at first because I couldn't find any other classes that it was conflicting with; it was conflicting with the namespace instead.
If you copy&paste your pages don't forget to rename class names. Otherwise you get this error also with "Type already defines a member called 'OnGet' with the same parameter types"
look this happend to me when I created new file inside a folder with the same name of class in the project { folder name : Folder } and there is class name { Folder } so the namespace was the namespace.Folder so that the compiler assume that the cass defined in two places
in new file :
namespace APP.Folder
{
partial class NewFile
{
// ....
}
}
in the other file (the file that hase the problem):
namespace APP
{
partial class Folder
{
// ....
}
}
-- so you can edit the folder name or remove the .Folder from the namespace at the new file
I know this is an older post, but I thought it might help someone else if I shared my experience with this error. For me, I was working in Visual Studio 2019 and using Xamarin Forms. I received this error message when I created a new folder and named it the same as a Content Page I had made previously. Apparently we're not supposed to do that...
Anyways, I had to rename the folder then go through to each individual Content Page within the folder are change their namespace (in their .cs file) as well as the x:Class within their ContentPage tag (in their .xaml file) to reflect the folder's new name.
That's what worked for me. I hope it is helpful to someone else in the future should the error rise again.
I've had this problem recently, all i did is rename the file and class then build. then return again the original filename. It worked.
This happened to me, I noticed that there was actually another class with that same name under the same namespace "OtpService.Models.Request", so all I did was to just change the namespace of the 2nd class to "OtpService.Models.Request.ExtraObj". I did this because I did not want to change the name of the conflicting class to anything else.
I came across this partial class problem in a winform of a solution after converting from .net 4.5.1 to 4.7.2.
Initially the problem the compiler was not complaining about partial class but the use of properties.default...without qualification. After adding Global::solnNameSpace. qualifiers, then I got the partial class problem.
after viewing answers in this thread, I look at the resource designer file, I found it was generated with explicit solnNameSpace while the classes in the solution did not. Also the solnNameSpace is the same as the name of the problematic class name.
To fix the problem with the least effort and time I backed out Global... qualifier and removed the explicit namespace ... and end statements from the resource designer file. I know I may get in trouble later on if there were changes that cause auto generation of the resource designer file but I was was under tight deadline. I made documentation on the temp change instead of a better long term solution since the solution is under no change allowed for nature of the solution and multi project use.
I had this problem. It was due to me renaming a folder in the App_Code directory and releasing to my iis site folder. The original named folder was still present in my target directory - hence duplicate - (I don't do a full delete of target before copying) Anyway removing the old folder fixed this.
when you have tried everything else and still get the same trouble, there is a way out; however it will be tedious and need careful preparation.
Start another new project using existing files, or edit the project .csproj file if you are proficient in editing csproj (need backup). I will list steps for new project.
preparation:
note all references and their sources
note all included files from another project
rename the orginal projectname.csproj file
close solution/project
start new project using existing files(you will get errors from references)
add back the noted references
include/add existing file from other project(s)