asp.net core with resource file (resx)
<p>I have a project in ASP.Net Core that need to include a image from a resource file (to generate a PDF).</p>

<p>So, I create a new resource file using Visual Studio (Add > New Item > Resources File), named Resource.resx</p>

<p>Using the Managed Resource Editor (default editor of Visual Studio), I included a new image named logo.png.
A new file named <code>Resource.Designer.cs</code> was created with a method listed below:</p>

<pre><code>public static System.Drawing.Bitmap logo {
    get {
        object obj = ResourceManager.GetObject("logo", resourceCulture);
        return ((System.Drawing.Bitmap)(obj));
    }
}
</code></pre>

<p>Now, only to test, I created the following code:</p>

<pre><code>var logo = Resources.logo;
</code></pre>

<p>This threw a new exception, with the following content:</p>

<p><code>An unhandled exception of type 'System.InvalidCastException' occurred.
 Additional Information: Unable to cast object of type 'System.String' to type 'System.Drawing.Bitmap'.</code></p>

<p>I tried all from this link too:
<a href="https://weblogs.asp.net/jeff/beating-localization-into-submission-on-asp-net-5" rel="nofollow noreferrer">https://weblogs.asp.net/jeff/beating-localization-into-submission-on-asp-net-5</a></p>

<p>but the results are the same.</p>

<p>If I make this code on a console application, everything works correctly.</p>