Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.NotSupportedException for .Net Core 3.1.3 #268

Closed
bezzad opened this issue Apr 26, 2020 · 6 comments · May be fixed by #448
Closed

System.NotSupportedException for .Net Core 3.1.3 #268

bezzad opened this issue Apr 26, 2020 · 6 comments · May be fixed by #448
Labels
area:.NET Core .NET Core related issues area:WPF/UWP WPF/UWP related issues more info needed up for grab Pull requests are welcome.

Comments

@bezzad
Copy link

bezzad commented Apr 26, 2020

When I try to obfuscate a MyApp.dll of the .Net Core 3.1, I get the following message:

Unhandled Exception: System.NotSupportedException: This .resources file should not be read with this reader. The resource reader type is "System.Resources.Extensions.DeserializingResourceReader, System.Resources.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51".
   at System.Resources.ResourceReader._ReadResources()
   at System.Resources.ResourceReader.ReadResources()
   at Obfuscar.Obfuscator.GetXamlDocuments(AssemblyDefinition library)
   at Obfuscar.Obfuscator.RenameTypes()
   at Obfuscar.Obfuscator.RunRules()
   at Obfuscar.Program.Main(String[] args)

My obfuscar config is like this:

<?xml version="1.0" encoding="utf-8" ?> 
<Obfuscator>
  <Var name="InPath" value="..\..\output\release\netcoreapp3.1" />
  <Var name="OutPath" value="$(InPath)\Obfuscated" />
  <Var name="KeepPublicApi" value="false" />
  <Var name="HidePrivateApi" value="true" /> 
  
  <Module file="$(InPath)\MyApp.dll" />
</Obfuscator>

Do you support this version of .Net Core or not?

@lextm lextm added area:WPF/UWP WPF/UWP related issues more info needed labels Apr 29, 2020
@lextm
Copy link
Member

lextm commented Apr 29, 2020

@bezzad do you have a small sample project to reproduce this issue?

@lextm
Copy link
Member

lextm commented Apr 30, 2020

@schmidtjohannes for that compiler issue, use tools like ILSpy to analyze the referenced assemblies and see where that namespace goes.

You should always post new issues, because this issue was opened by another user and was for completely a different thing.

@obfuscar obfuscar deleted a comment from schmidtjohannes Apr 30, 2020
@obfuscar obfuscar deleted a comment from schmidtjohannes Apr 30, 2020
@polarlightning
Copy link

polarlightning commented May 12, 2020

I have maybe related case. I am trying to obfuscate net462 executable in a Docker "builder-container" (Linux container), which is based on Microsoft's Docker base image "mcr.microsoft.com/dotnet/core/sdk:3.1", but Obfuscar is not even starting. When I try to run obfuscar.console (2.2.15) there asking just its version with -V, the below are emitted, indicating, AFAIK, that Obfuscar could run only in .NET Core 2.1.0. Obfuscar was installed in the image with "dotnet tool install --framework netcoreapp3.1 --global Obfuscar.GlobalTool --version 2.2.15", but it seems --framework -parameter is ineffective here.

# ls -l /root/.dotnet/tools
-rwxr-xr-x 1 root root 86584 May 12 16:34 obfuscar.console

# /root/.dotnet/tools/obfuscar.console -V
_It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '2.1.0' was not found.
  - The following frameworks were found:
      3.1.3 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]

You can resolve the problem by installing the specified framework and/or SDK.

The specified framework can be found at:
  - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=2.1.0&arch=x64&rid=debian.10-x64
# exit_

@lextm
Copy link
Member

lextm commented May 12, 2020

@polarlightning Please read #255 . That's a different issue.

@lextm lextm added the up for grab Pull requests are welcome. label Aug 22, 2020
@molesmoke
Copy link

molesmoke commented Nov 10, 2020

I'm also seeing this behavior. For me, it manifests in a winforms project when a form's localizable property is set to true.
Please find a small test project attached that reproduces the issue.

WindowsFormsApp2.zip

jeremy-visionaid added a commit to jeremy-visionaid/obfuscar that referenced this issue Nov 25, 2020
Swallow NotSupportedException in GetXamlDocuments for resources in
localized WinForms applications in .Net Core 3.1 and later.
jeremy-visionaid added a commit to jeremy-visionaid/obfuscar that referenced this issue Nov 25, 2020
Swallow NotSupportedException in GetXamlDocuments for resources in
localized WinForms applications in .Net Core 3.1 and later.
@techaimail
Copy link

We have the same problem in a WPF .NET 5 app with VStudio 2019 Enterprise, please is there any solution?
We are using Obfuscar 2.2.29

Loading assemblies...Extra framework folders: Done.
Hiding strings...

Unhandled Exception: System.NotSupportedException: This .resources file should not be read with this reader. The resource reader type is "System.Resources.Extensions.DeserializingResourceReader, System.Resources.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51".
   at System.Resources.ResourceReader._ReadResources()
   at System.Resources.ResourceReader.ReadResources()
   at Obfuscar.Obfuscator.GetXamlDocuments(AssemblyDefinition library)
   at Obfuscar.Obfuscator.RenameTypes()
   at Obfuscar.Obfuscator.RunRules()
   at Obfuscar.Program.Main(String[] args)
Renaming:  fields...Parameters...Properties...Events...Methods...Types...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:.NET Core .NET Core related issues area:WPF/UWP WPF/UWP related issues more info needed up for grab Pull requests are welcome.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants