You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are in the process of migrating an application from the .NET Framework to .NET Core 2, but it looks like the ResourceReader cannot process a valid resx file.
When I create the ResourceReader I get
System.ArgumentException: Stream is not a valid resource file.
at System.Resources.ResourceReader._ReadResources()
at System.Resources.ResourceReader.ReadResources()
at System.Resources.ResourceReader..ctor(String fileName)
public IEnumerable<Tuple<string, string>> Parse(string fileName)
{
var results = new List<Tuple<string, string>>();
fileName = Path.GetFullPath(fileName);
if (!string.IsNullOrWhiteSpace(Path.GetDirectoryName(fileName)))
Directory.SetCurrentDirectory(Path.GetDirectoryName(fileName));
using (var reader = new ResourceReader(fileName)) // This blows up
{
foreach (DictionaryEntry pair in reader)
{
results.Add(new Tuple<string, string>(pair.Key as string, pair.Value as string));
}
}
return results;
}
ResourceReader is for reading .resources files. .resources files are binary compiled files.
ResourceReader is not for reading .resx files. .resx files are xml source files. You need to use GenerateResource build task to compile .resx file into .resources files. Typically, you do not need to call this build task explicitly - it gets called implicitly by just having the .resx file in your solution.
This is same between .NET Core and .NET Framework.
We are in the process of migrating an application from the .NET Framework to .NET Core 2, but it looks like the ResourceReader cannot process a valid resx file.
When I create the ResourceReader I get
Here is a gist to the contents of the resx file.
The text was updated successfully, but these errors were encountered: