After a struggle with creating a database (first with an entity framework, after without), we have a database (and an EntityModel_HFFContext file we don't use, it's not connected). Normal work proceeded, and I installed a NuGet-package for an MVC sitemap.
From that moment, the project worked fine, but after a couple of days two warnings came up about two files missing: "The parent file, 'EntityModel_HFF.tt', for file 'locatie.cs' cannot be found in the project file." ("HFF" is the project name in here) and then those multiplied themselves into errors: "Source file 'locatie.cs' cannot be found" in a CSC file I cannot find.
These two files ('locatie.cs' and 'klant.cs') are not in any view, but somehow they are displayed outside all folders, saying they do not excist (see this screencapture). I have tried to delete those files manually, but that did not have any success. I have tried some other ways too, but that resulted into the complete deletion of the database, so now I am somewhat desperate.
I have no idea where to look and what to do, to get rid of these two files (or probably references to these files, since we don't use them at all), so I don't have these errors anymore. Has anyone of you have a clue of where I need to look (e.g. where this CSC file is) and what I need to adjust to fix this?
Maybe it can be useful to know I use Visual Studio 2013.
Update
I fixed the errors by unloading the project, editing the .csproj file and commenting out
<Compile Include="klant.cs">
<DependentUpon>EntityModel_HFF.tt</DependentUpon>
</Compile>
(and the other one too). Now these errors are gone - is this a safe way to do this?
The reason why you get the error is because when you deleted the locatie.cs and klant.cs file, you didn't remove them from the project solution itself, therefore, Visual Studio is expecting the file to be part of the project but is unable to find them, which explains the yellow warning signs.
Like what you said, all you have to do is to remove the files from the solution as they no longer exists. So yes, it is safe to comment out that portion in the .csproj file.
Although, I would like to mention that you didn't have to go to that much trouble, all you had to do was to delete the file in your solution in Visual Studio, since they no longer exists anyway.
I am fairly new to TortoiseGit. Wondering, if I get a conflict on a .resx file, how do I resolve it during a merge? For example, I could select "using theirs" off of the menu, try to do a pull and push, but is this the right approach? Can I somehow use theirs and rebuild it with my project changes? The differences (as well as mixed up contents compared to the respository) are many - to many to do a real merge. Thanks for looking?
This is an old question that has not been answered. However resolving conflicts in resx files is driving me nuts. The main issue seems to be that resx files can be changed randomly when updated. Visual Studio does not care about the order. As a result a lot of trivial 'conflicts' can arise because of elements being in different places in the two resx files.
I found the answer is to sort the resx files by name attribute before the merge. This article explains how it is done and provides a simple command line tool. The author refers to how it can be integrated into different diff/merge tools. His example is Beyond Compare 3 (which I use) and this article gives instructions on how to do the integration.
I tried this and for the first time I managed a merge of branches with GUI changes without loss or hair or hours of manually repairing things in Visual Studio.
I hope this answer is relevant and may help folks as it helped me
My solution is a bit hacky but it takes care of the Resources.designer.cs file too.
VS auto generates Resources.designer.cs from Resources.resx so i just fix the later and regenerate Resources.designer.cs
Typically I do the following stages:
close VS
command line : git merge (merges src branch to current)
i see the conflict in Resources.resx
delete Resources.Designer.cs file (it will get regenerated later)
open Resources.resx with some resolve tool (i just use notepad++)
resolve the conflicts manually (in notepad, typically i search for "<<<", remove the "<<<","-----",">>>>" lines add the missing and save.
open VS with the project, it will complain about missing Resources.designer.cs file.
double click Resource.resx, add at the end some fake row + save (this recreates Resources.designer.cs)
del the fake row i created before and save.
I downloaded the source code for this JiraSVN plugin, and opened the .sln file in VS2010. I was immediately greeted by this warning:
A custom tool 'SettingsSingleFileGenerator' is associated with file
'Properties\Settings.settings', but the output of the custom tool was
not found in the project. You may try re-running the custom tool
by right-clicking on the file in the Solution Explorer and choosing
Run Custom Tool.
I'm not familiar at all with this custom tool or what it is supposed to do, nor how to resolve the problem. (I tried the suggestion to right-click and re-run the custom tool, but nothing happened.)
When I attempt to build, it fails with this error:
Source file 'C:...\Properties\Settings.Designer.cs'
could not be opened ('Unspecified error ')
Taking a look at the Solution Explorer, I see the following entry under one of the projects:
└─Properties
└─/!\ Settings.settings
└─/!\ Settings.Designer.cs
(where the last two entries have exclamation point warning icons.)
I tried to exclude those two entries from the project, but got many more errors.
How do I resolve this? Is the build broke, or have I just failed to set something correctly?
I suddenly encountered this same error while attempting to compile my own saved code. The code would no longer compile, even though the last time I had saved it, everything was fine.
I simply deleted "SettingsSingleFileGenerator" from the Custom Tool line of the properties of the Settings file (mine was in My Project/Settings folder, your error message should tell you where this is located). Removing this allowed me to compile again smoothly.
In the context menu of your project go to Properties - Settings - "Click here to create ...". This created an empty properties file which sufficed for my project.
Well, the build was indeed broken. There is a fork by PatrickMauer that reconstructs the missing files.
Open the .csproj file in a text editor and remove the LastGenOutput tag. Visual Studio thinks that there was some error during settings file generation if the LastGenOutput tag is present and keeps issuing a warning during build.
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings1.Designer.cs</LastGenOutput>
</None>
Recently I created new Form called WorkersScreen. When I try to run the project I got this error:
Error 1 Two output file names resolved to the same output path:
"obj\x86\Debug\DryWash.WorkersScreen.resources"
What does it mean and how does one resolve it?
This can happen in the event of two .resx files pointing to the same form. Mostly happens when renaming forms (other reasons may apply, I'm not exactly sure)
If your particular form files looks like this:
Form1.cs
Form1.designer.cs
MyFormerFormName.resx
Form1.resx
then that usually implies that you renamed the form but Visual Studio didn't remove the old .resx file. Once you delete the file (in this example MyFormerFormName.resx) manually, the error should be gone upon next build.
Find Duplicates by Editing Project File
Note the name of the .resx failure.
Unload the project first by right clicking on your project then click Unload Project.
Right click your project again and click edit project.
It will show you some code, look (or Search within the file for the resx in step 1) for the duplicate values which in my case is look like this
<EmbeddedResource Include="frmTerminalSerial.resx">
<DependentUpon>frmTerminalSerial.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmVisual.resx">
<DependentUpon>frmVisual.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmVisual.resx">
<DependentUpon>frmVisual.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="My Project\Resources.resx">
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
<CustomToolNamespace>My.Resources</CustomToolNamespace>
<SubType>Designer</SubType>
</EmbeddedResource>
Notice this portion, it is a duplicate!
<EmbeddedResource Include="frmVisual.resx">
<DependentUpon>frmVisual.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmVisual.resx">
<DependentUpon>frmVisual.vb</DependentUpon>
</EmbeddedResource>
Delete one of them so it will look like this
<EmbeddedResource Include="frmTerminalSerial.resx">
<DependentUpon>frmTerminalSerial.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmVisual.resx">
<DependentUpon>frmVisual.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="My Project\Resources.resx">
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
<CustomToolNamespace>My.Resources</CustomToolNamespace>
<SubType>Designer</SubType>
</EmbeddedResource>
Save it, right click to your project then click reload project. You are done!
Normally, if you create a migration like this
Add-Migration "UpdateProducts"
Visual Studio will create a migration with a class name like UpdateProducts. If you add a new migration later using the same migration name, it will generate a migration with a class name like UpdateProducts1., automatically adding an incremented digit to the end as a suffix. Every time you generate a new migration, the number goes up by one.
In our case, for some reason, VS got confused, and started generating subsequent migrations with the same class name as existing migration, so that that there were two auto generated migrations with the same name.
Simply changing the class name of the new migration clears the problem.
i did a little search
i had the same problem
it's probably beacause your form has two .resx
if you try to delete one, the problem will be gone
my form:
Form1.Designer.cs
Form1.resx
Log_in.resx
Form1
i deleted Log_in.resx and my program worked again
I just got this issue using VS 2019 community edition.
I didn't have duplicate .resx files. I didn't have duplicate .cs files.
I couldn't find the solution online.
To fix the problem, I cleaned the solution and then restarted VS.
Not sure why, but it worked. Hope this helps.
I had the issue and it was caused because I had a partial class of a custom control.
I had accidentally created a .resx file for the partial
I think I did this by hitting shift F7 on the partial class and producing the empty designer form.
Removing the .resx file on the partial class resolved it for me. I was using version control and it was showing that it was a new file.
Hope this helps
Make sure you don't have two .resx files. See in your project under YourServiceName.cs. Works for me.
This just happened to me. I had accidentally "Drag and dropped" a form into another. It ended up making a copy of it called "Copy of ". I deleted it and the problem went away.
This happened to me when I copied a form to reuse most of the functionality and then renamed the form. I went to the directory referenced, found that there was in fact only one file, copied the file in question, renamed it to reference the name of my new form, and then pasted the new file back in the directory.
I don't think this is a good practice (I'm new to C#) but it did work, instead of having to recreate everything. I also needed to update the form name in a few places throughout the solution, surprising in the original form as well as in the new form.
Copying forms does not seem like a good idea.
In my case, the issue was caused by an EmbeddedResource tag for a designer.resx file that somehow got added to the .csproj file.
Specifically, the following:
<EmbeddedResource Include="Forms\frmMenu.designer.resx">
<DependentUpon>frmMenu.designer.cs</DependentUpon>
</EmbeddedResource>
Search in all project the class reported in error list, like in this question case DryWash.WorkersScreen it could be repeated in another file with different file name but inside same class name.
I got this problem when I accidentally generated a migration with the same name as a business object.
The solution is to delete the migration and then create a new one with a different name.
In my case I had to to open the .csproj in Note++ and looked for .resx files in EmbeddedResource tags I found some strange .resx with strange language suffix example.aa.resx other files were normal files either with no language suffix or with *.ar suffix, I deleted the creepy embedded resource tag and that fixed the issue for me.
I had this problem today.
Some how the Form.Designer had an extension of .resx, for my solution it was TestForm.Designer.resx. There was already a TestForm.resx. I cleaned the solution, closed down VS, deleted the TestForm.Designer.resx file, and then restarted VS. I still had the error.
I then closed down VS and opened the .proj file using NotePad++ and found that the TestForm.Designer.resx was still referenced. I deleted the embedded resource.
<EmbeddedResource Include="TestForm.Designer.resx">
<DependentUpon>TestForm.Designer.vb</DependentUpon>
</EmbeddedResource>
Then I opened VS and built....It work's again!
This happened to me when I run Add Migration command and gave same name as my project name as migration class. I removed all migration classes and added new one, solution build again.
In my option, help delete one *.resx for every form where the error raised
Detail INFO
In our project we have 6 *.resx for every form for localization (DE,GB,SK,RU,SRB) and if i delete (from VS) FormName.sr-Latn-CS.resx than the error disappeared. If i try deleted FormName.en-GB.resx it did not help. Error disappeared just for delete sr-Latn-CS.resx (maybe a designer can not solved two - ). I first saw this error when I migrated project from VS 2010 Win 7 to VS2010 Win 10.
If this problem appeared while you were working with EntityFramework and was trying to Add-Migration, the solution is simple: delete Migrations folder (in the Solution Explorer) and execute Enable-Migrations. Backup migrations if you need.
For me the issue was copying and pasting a .aspx, and not renaming the code behind class files to match the name for the copied aspx file. Changing the code behind and designer class names worked.
I had the same issue, what I did was delete my migration files (via the studio), after I updated the database.
As #WimOmbelets stated in his 2013's answer, copying a Form is a very sure way to reproduce this annoying error, at least in VS 2017, 2019 and 2022.
As Vince De Giorgio said in his 2019's answer, I too didn't have duplicate .resx or .cs files and I didn't have duplicate ...EmbeddedResource Include= .../> tags in .csproj.
Deleting .resx files (icons gone, obvious) for both involved forms, clean the solution and then restart VS is a poor man's way to solve, because every time I add again an icon or another resource, same annoying error. It is still worse: to recover, I had to Git stash all modifications; if I revert manually all changes, to the point that Git does not recognize any changes, the error continues (!!!) even after cleaning, restarting VS and rebuilding.
To fix the problem in VS 2019 and 2022:
Every time that I want to copy a form, I:
Exclude Form to be copied from project (exclude, DO NOT DELETE!)
In Windows Explorer I create a Form's copy and open them (.cs and designer.cs) with Visual Code (whatever)
In Visual Studio I create Add a New Form with a different name - of course
Paste back designer.cs and .cs codes from VS code; change namespace, class name and Ctor
Include again in Project previous Form
Enjoy
Never more had this problem.
I had the same issue in Visual Studio 2022 with a WinForms application in .NET 6.
In this case, I had added a partial class in it's own .CS file to handle custom setup outside of the Designer-generated InitializeComponent.
The next time that I opened the file, Visual Studio 2022 tried to open this in the WinForm Designer. This added a redundant .resx file to the project.
Delete the newly added .resx to correct the error.
from the link:
https://learn.microsoft.com/en-us/visualstudio/msbuild/errors/msb3577?view=vs-2022
<EmbeddedResource Include="MyResources.resx">
<ManifestResourceName>CustomName</ManifestResourceName>
</EmbeddedResource>
open project file and ensure that the value given for CustomName is different for each generated resource file.
I thought that I would post on at least one random forum after encountering this error in hopes of easing someone elses problems. I searched many google sites and none had my exact problem. My cause was similar, but different in some ways.
I actually had a partial class spread across multiple files. this class was a form class. This was successful in itself and didn't cause a problem. However, this caused the new class to keep its unique file name while maintaining a split 'class Form' code. It was most likely not kosher practice, but none the less it happened at the time. It seemed like a good alternative to get a lot of cluttered code out of the way. Needless to say, next time I will just use regions or some other alternative.
The error then occured when I tried to take the code from the 2nd file and copy/paste into a new non form file with just a class, as I had intended upon essentially turning it into a library and making the code a little more proper and readable. As I didn't know exactly what had caused the error when it happened and had made a small plethora of changes, it took some time to track. Even after reversing the code, I managed to miss a pair of methods.
The methods for the main form containing the class Form with initializeComponent and form constructor (load). A 2nd copy of these methods appeared to result in the same error. Even after deleting the extra code and extra form and resx files. I even tried deleting the legitimate resx file since it was not actively needed. I was unable to effectively track it, because any errors pointed to the legit versions of these code segments. Ctrl+F and backup copies are your friends.
Hope that helps someone
I confirm WimOmbelets answer given in the comments. This can apparently happen when you rename a class in VS2012 (I never had this in a prior version).
I can't be sure this is the cause, but one thing I did different from my normal way is I used F2 to rename it as opposed to changing it and then pressing control-.
I had the same issue when I renamed one of my Form classes using Ctrl + R + R which VS provides to rename things by default.
Then I somewhat got two classes with the same class name on 2 different files (*.cs).
class Bar { ... } // From Bar.cs
class Bar { ... } // This should've been Foo, from Foo.cs
The two Bar indicating the same resource file that one of them shouldn't.
It's a trivial issue but sometimes could be hard to find the cause because looking at cs files just can't say which one is what you should look for.
I'm writing an application that will enable the creation of SQL files within visual studio. The user will enter commands via the Package Manager console which will generate sql scrips and deposit them in a specific directory within the Visual Studio Project.
The problem I have is that, when the files are generated, they are present on the file system, but not in Visual Studio. This is expected of course, as I need to then go and actively include the files within Solution explorer, but this isn't what I want. I want the files to "Magically" appear in solution explorer immediately after they're generated.
I've seen various solutions to similar problems mostly featuring amendments to the .csproj file such as this
<Compile Include="Sql\**\*.sql" />
but this isn't what i'm looking for. What i'm after is similar to how, for example, Entity Framework or MvcScaffolding work, where files / folders just magically drop into the project when commands run in PMC. I'm aware this runs off T4 templating, but that seems like too complex a solution for a simple issue like this.
I should qualify that there's no voodoo going on in the creation of the files, just plain old File.Create() stuff.
I'm open to any suggestions.
Thanks.
Check out this answer for a solution that worked for me. I have the same use-case where code outputs flat files and I need to include this output in the project.
At the end of your .csproj file add the following:
<Target Name="BeforeBuild">
<ItemGroup>
<Content Include="Sql\**\*.sql" />
</ItemGroup>
</Target>
IMHO, T4 is the way to go. You don't want to be bothering with older technologies for what you are trying to do.
Having said that, I wonder why is it required for the files to be added to the solution explorer? is it for source control purposes? (usually you don't want to source control auto generated files, you want to source control the original model).
Note that you could always click the 'show all' button and the files will appear in the solution explorer, without actually being a part of the solution.