Recently I created new Form
called WorkersScreen
. When I try to run the project I got this error:
Error 1 Two output file nam
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.
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.
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 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 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.
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.