Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resource (resx) file import

I have problem after importing resource files from one project to another.

I work with Visual Studio Ultimate 2013, C#, Visual Online.

I have Resource files in my projects. When I create a new project and import files and these resources to a new project, MY_RESOURCE.Designer.cs is not in its own MY_RESOURCE.resx section - it is next to it.

  • Normally, order of Resource files must be like this:

    Right order


  • But, in new project, it is like this - after importing:

    Wrong order

Also, in project's file (.csproj) I found, that structure of these files are different.

  • Normally:

    <Compile Include="Resources\Main\Main.en-US.Designer.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>Main.en-US.resx</DependentUpon>
    </Compile>
    ...
    <EmbeddedResource Include="Resources\Main\Main.en-US.resx">
      <Generator>PublicResXFileCodeGenerator</Generator>
      <LastGenOutput>Main.en-US.Designer.cs</LastGenOutput>
    </EmbeddedResource>
    

  • After import:

    <Compile Include="Resources\Main\Main.en-US.Designer.cs" />
    ...
    <EmbeddedResource Include="Resources\Main\Main.en-US.resx" />
    

I found some solutions like this problem's, to change Recourse's "Access Modifier" property (in it) from "No code generation" to "Public", but after this, resx file creates new child - MY_RESOURCE1.Designer.cs (not my MY_RESOURCE.Designer.cs), so this is not solution for my problem.

So, insted of importing them, I have to create new Resource file and copy and paste the words from the old project's resource files to new one.

Can someone advice me the way to bind a Designer.cs file to resx file insted of copy-paste..?

like image 695
GuRAm Avatar asked Jan 05 '16 08:01

GuRAm


1 Answers

The C# code ("Main.en-US.Designer.cs") is automatically generated by VS, you have to check that Visual Studio is correctly managing your resx file. To achieve this, check the Custom Tool property for your resx file:

  1. Select your resx file
  2. Open the Properties tab
  3. Check "Custom Tool" property, make sure that "ResXFileCodeGenerator" value is present.

This should fix your issue.

like image 172
LucaMus Avatar answered Sep 21 '22 09:09

LucaMus