question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

System.Resources.MissingManifestResourceException when DependentUpon not specified and .resx path not match with Control/Form namespace

See original GitHub issue

Visual Studio Version: 16.3.0

Summary: .Net Core 3.0 Microsoft.NET.Sdk.WindowsDesktop UseWindowsForms = true System.Resources.MissingManifestResourceException when DependentUpon not specified and .resx path not match with Control/Form namespace.

Steps to Reproduce:

  1. Create new WindowsForms project (sdk style, net472).
  2. Add local resource to Form1 (e.g. BackgroundImage).
  3. Change Form1 namespace or move it to another folder in project.
  4. Build and run application.

Expected Behavior: Application starts and Form1 shown with set background image.

Actual Behavior: System.Resources.MissingManifestResourceException thrown when this.BackgroundImage = (System.Drawing.Image)resources.GetObject("$this.BackgroundImage"))) called.

Content of csproj file:

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

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net472</TargetFramework>
    <UseWindowsForms>True</UseWindowsForms>
  </PropertyGroup>

</Project>

Workaround: Add next item in csproj file:

  <ItemGroup>
    <!-- "NewFolder" is project subfolder where form has been moved. -->
    <EmbeddedResource Update="NewFolder/Form1.resx" DependentUpon="Form1.cs" />
  </ItemGroup>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
AdamDotNetcommented, Oct 10, 2019

I’ve been researching this too, lately. Try adding this property to your CSProj.

<PropertyGroup>
 <EmbeddedResourceUseDependentUponConvention>true</EmbeddedResourceUseDependentUponConvention>
</PropertyGroup>

Which I found via: /dotnet/sdk/pull/3533

Remove your workaround <EmbeddedResource Update="..." after adding the above property and you should be good to go.

Note that this flag is set to true for .Net Core 3.0+ and .Net Standard 2.1+, but needs to be opted in like this for other TFMs. This flag has worked for me on my projects using Sdk="Microsoft.NET.Sdk.WindowsDesktop" WinForms projects targeting net48 where the namespace of the form did not match the folder it was in.

0reactions
ds1709commented, Oct 11, 2019

Yes, it works now. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What does MissingManifestResourceException mean and ...
All I needed to do to fix this problem was to right-click the Resources.resx file in the Solution Explorer and click Run Custom...
Read more >
MissingManifestResourceExcepti...
The exception that is thrown if the main assembly does not contain the resources for the neutral culture, and an appropriate satellite assembly...
Read more >
How I can fix this error in windows form
This problem occurs when the default name space of your project mismatch with your Resources.Designer.cs namespace. In order to resolve this ...
Read more >
The "System.Resources.MissingManifestResourceException
MissingManifestResourceException : Could not find any resources appropriate for the specified culture or the neutral culture." error occurs under ...
Read more >
Problems with localization in c# using satellite Dll's, it ...
Find answers to Problems with localization in c# using satellite Dll's, it keeps giving me Err: System.Resources.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found