9

I'm getting the error:

Two output file names resolved to the same output path: "obj\Debug\Project1.Form1.resources"

This error comes while trying to run a windows form application I created. Some searches showed me that this occurs due to the occurrence of two .resx files. I have two .resx files in my application. Also I have two forms in my application. I created the second form by copying the first form and renaming and modifying the copy. The two .resx files are form1.resx and form2.resx. How can I remove this error?

2
  • When you was renaming the class of the second form, did you use the auto-update feature of Visual Studio? if so, it may has changed the class name of the first form too. Commented Jan 26, 2015 at 19:10
  • @Ahmad I don't remember the details of this issue anymore. Commented Jan 29, 2015 at 4:39

7 Answers 7

7

Though I don't know why will you do it, you can use these instructions to copy properly a form. It is not recommended. It is better to inherit or use user control. But if you must:

  1. Delete the second form.
  2. Recreate it by actually creating a form
  3. Copy the InitializeComponent method from form1.designer to the new form
  4. Also copy the part below InitializeComponent.
  5. Copy the code of form1 to the new form, make sure to fix the constructor
  6. Please do not copy a full form using copy paste

EDIT

When someone pushes the change page button you can do:

  private void button1_Click(object sender, EventArgs e)
  {
     Form2 frm = new Form2(NextPage);
     frm.Show();
     this.Hide();
  }

Now this is very basic syntax. you might want to have a master form that holds all the forms so you won't create over and over new forms.

The design is up to you. this example will give you basics on how to open and close forms.

Sign up to request clarification or add additional context in comments.

7 Comments

I'm trying to create multi-page fill form, with each page in each form. Do you have any suggestions? I have just started the designing. Thank you for the answer. It helped me and I will accept this answer.
@Foreever yes i have some suggestions but first tell me what's a "page"? is it text? is it an object? at general you can take a form and create several instances of it, each with different "page" as a member of the form. then display the "page" that you got in this form
By Page I meant pages as in a PDF or Word file. After filling some textboxes in page 1 then by clicking next button one could go to the next page,which contains another set of textboxes to be filled. Can you tell me in brief how to create many instances of the same form?
Since the instances are created programmatically, shouldn't I design the page corresponding to that instance programmatically as well.
@Foreever for what you want you can do it all in one form and change the textbox1.Text property. i'll edit the answer to show you how to show and hide pages
|
3

If you don't need the resx files you can just delete them and this problem goes away.

Comments

1

This error may also occur if you use Windows10 and you have localiztion resources for CR-Cyrl-CS, CR-Latn-CS cultures. Windows10 doesn't support them any more.

Comments

1

I encountered this problem while making a form application. When I changed the form name, the compilation problem arose due to the same error. In Visual Studio, I saw that a .resx file with 2 different names was created in the sub-tabs of the form that I changed its name in the Solution Explorer section. I deleted oldname.resx and it was fixed.

Comments

0

In my case, it was not showing me 2 copies of .resx files. I simply restarted Visual Studio 2010 and the problem disappeared.

Comments

0

I added twice a second form called FormSettings to my project and later I was getting the described error. In order to fix it, I removed FormSettings from the project. After that, I renamed all the files whose name was FormSettings to FormSettingsOld. When I built the application, it was giving errors about FormSettings. I performed a search for all files in the project which contained a reference to FormSettings. I found that ProjectName.csproj was making reference to FormSettings and I deleted the duplicate XML entris related to FormSettings, such as

<Compile Include="FormSettings.Designer.cs">
<DependentUpon>FormSettings.cs</DependentUpon>
</Compile>
<Compile Include="FormSettings.Designer.cs">
  <DependentUpon>FormSettings.cs</DependentUpon>
</Compile>

Comments

-1

When copying a form it seems that the class name of the source form is being renamed to the name of the new form, at least if you rename the new form. I restored the original name of the destination form (class file, constructor and designer file). Remember also to go through any usage of the original class name as changes also are need here. That solved the problem. (Visual Studio 2010)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.