2

I want to write in my .resx file. I have used ResXResourceWriter which works fine in Windows form but doesn't available in .Net Core application. It needs system.Windows.Forms but .net core don't reference to it.

ResXResourceWriter resx = new ResXResourceWriter(hostingEnvironment.WebRootPath + "\Localization\LabelResource.EN.resx")

5
  • 1
    What exactly is your question? System.Windows.Forms does not exist in .net core. If you are looking for localization please see Globalization and localization in ASP.NET Core Commented Jan 17, 2019 at 17:18
  • I actually want to dump database data into .resx file. Is it possible in .net core? Commented Jan 17, 2019 at 17:25
  • The ResXResourceWriter class is not available in .net core, to create one you would need to use .net framework Commented Jan 17, 2019 at 17:27
  • Can you please tell me the procedure? Commented Jan 17, 2019 at 17:36
  • Not sure what procedure you are talking about, if you want to learn about wrting resource files, look at System.Resources Namespace Commented Jan 17, 2019 at 17:39

2 Answers 2

11

If you already have .net Core 3.0 (or more) installed and want to add a reference to an existing project (.csproj).

You can only add the following tag:

<UseWindowsForms>true</UseWindowsForms> into the following section: <PropertyGroup>

I think it is new: Menu "Edit Project File" in project Contextual Menu in Visual Studio.

Like so (added into a WPF project):

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <UseWPF>true</UseWPF>
    <UseWindowsForms>true</UseWindowsForms>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\GeneralCore\GeneralCore.csproj" />   </ItemGroup>

</Project>
Sign up to request clarification or add additional context in comments.

1 Comment

3

You will currently need to use the .Net Core 3.0 Preview, as System.Windows.Forms is new in .Net Core 3.0. From the System.Windows.Forms repository:

You can create a new WinForms application with dotnet new command, using the following commands:

dotnet new winforms -o MyWinFormsApp
cd MyWinFormsApp
dotnet run

2 Comments

I think I didn't make my question clear enough. Actually, its a web site built on .net core MVC
Based on the comments in your question, .resx files are just XML files. You should be able to use XDocument to open and change them.

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.