Embedded resources of referenced project #299

Closed
opened 2026-01-29 16:36:00 +00:00 by claunia · 1 comment
Owner

Originally created by @Silver-Rabbit on GitHub (Apr 3, 2019).

I have set up an Electron.NET app with a reference to another project.
This project contains embedded resource files, mainly text files containing SQL queries, including a .resx file to easily access them.

When trying to access the resources in my Electron.NET application, I get the following output:

SqlQueries\List.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8

So instead of the content of the file, I get some kind of description of the embedded resources.
When using the project in a basic .NET console application without Electron.NET, it works fine.

Did I miss something or is this a bug during the compilation?

Originally created by @Silver-Rabbit on GitHub (Apr 3, 2019). I have set up an Electron.NET app with a reference to another project. This project contains embedded resource files, mainly text files containing SQL queries, including a .resx file to easily access them. When trying to access the resources in my Electron.NET application, I get the following output: SqlQueries\List.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 So instead of the content of the file, I get some kind of description of the embedded resources. When using the project in a basic .NET console application without Electron.NET, it works fine. Did I miss something or is this a bug during the compilation?
Author
Owner

@Silver-Rabbit commented on GitHub (Apr 30, 2019):

Seems that this is a problem with the packaged msbuild of the .NET Core CLI.
See the following issues:
https://github.com/dotnet/cli/issues/7534
https://github.com/Microsoft/msbuild/issues/2221

A workaround for this problem is to use System.Reflection:

var assembly = Assembly.GetExecutingAssembly();
var resourceName = "ResourcePathToTheFile";
Stream stream = assembly.GetManifestResourceStream(resourceName);
StreamReader reader = new StreamReader(stream);
string query = reader.ReadToEnd();
@Silver-Rabbit commented on GitHub (Apr 30, 2019): Seems that this is a problem with the packaged msbuild of the .NET Core CLI. See the following issues: https://github.com/dotnet/cli/issues/7534 https://github.com/Microsoft/msbuild/issues/2221 A workaround for this problem is to use _System.Reflection_: ``` var assembly = Assembly.GetExecutingAssembly(); var resourceName = "ResourcePathToTheFile"; Stream stream = assembly.GetManifestResourceStream(resourceName); StreamReader reader = new StreamReader(stream); string query = reader.ReadToEnd(); ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#299