Set EXE language in C# WPF

Amol Bhavsar 0 Reputation points
2024-04-05T08:11:41.9333333+00:00

I am working in C# WPF and want to change EXE Language which appears in EXE Properties-Details Page- Language. Originally the "Language" is "Language Neutral". Even though I am changing the "Assembly Neutral Language" from project properties, the EXE properties from explore are not showing the changes language from Visual Studio 2022.

However C++ have an option to use .RC file but I need option which will work in C#.Net.

Please let us know way to achieve this.

Thanks in advance for any suggestions.

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,674 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,266 questions
{count} votes

1 answer

Sort by: Most helpful
  1. gekka 6,671 Reputation points MVP
    2024-04-07T11:30:14.8933333+00:00

    "Assembly Neutral Language" in project property is a setting for NeutralResourcesLanguageAttribute.
    20240407_1

    The correct setting to display in the file properties is "Win32 Resources - Resource file" in project property.
    20240407_2

    You should create like following RC file, and add task for generate RES file in your project file.

    1 VERSIONINFO
     FILEVERSION 1,0,0,1
     PRODUCTVERSION 1,0,0,2
     FILEFLAGSMASK 0x3fL
    #ifdef _DEBUG
     FILEFLAGS 0x1L
    #else
     FILEFLAGS 0x0L
    #endif
     FILEOS 0x40004L
     FILETYPE 0x1L
     FILESUBTYPE 0x0L
    BEGIN
        BLOCK "StringFileInfo"
        BEGIN
            BLOCK "040904b0"
            BEGIN
                VALUE "CompanyName", "TODO: English CompanyName"
                VALUE "FileDescription", "TODO: English Description"
                VALUE "FileVersion", "1.0.0.3"
                VALUE "InternalName", "TODO:  English InternalName"
                VALUE "LegalCopyright", "Copyright (C) 2024 English Copyright"
                VALUE "OriginalFilename", "TODO:"
                VALUE "ProductName", "TODO:"
                VALUE "ProductVersion", "1.0.0.4"
            END
        END
        BLOCK "VarFileInfo"
        BEGIN
    	VALUE "Translation", 0x409, 1200 //English,UTF-16LE
        END
    END
    
    <Project Sdk="Microsoft.NET.Sdk">
    
    	<PropertyGroup>
    		<OutputType>WinExe</OutputType>
    		<TargetFramework>net8.0-windows</TargetFramework>
    		<Version>1.0.0</Version>
    		<UseWPF>true</UseWPF>
    	
    		<!--<NeutralLanguage>en-US</NeutralLanguage>-->
    	</PropertyGroup>
    
    	<ItemGroup>
    		<None Include="test.rc" /> <!-- create rc file in project folder-->
    	</ItemGroup>
    	<Target Name="generate_win32resource" AfterTargets="ResGen">
    		<Message Text="Generate Win32 Resourcefile" />
    		<Exec Command="&quot;C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x86\rc.exe&quot; /v /nologo /l411 test.rc" WorkingDirectory="$(ProjectDir)" />
    	</Target>
    	<PropertyGroup>
    		<!--<GenerateAssemblyInfo>false</GenerateAssemblyInfo>-->
    		<Win32Resource>test.res</Win32Resource>
    	</PropertyGroup>
    </Project>
    

    NOTE: The path to rc.exe must be changed to match the version of C++ installed your environment.