ModPhuserEx icon indicating copy to clipboard operation
ModPhuserEx copied to clipboard

Obfuscate DotNetCore lib failed.

Open Dev-SlimGIS opened this issue 8 years ago • 4 comments

I created a very simple class such as:

using System;

namespace ClassLibrary1
{
    public class Class1
    {
        public void Go()
        {
            Console.WriteLine("Hello");
        }
    }
}

Protections settings with anti ildasm only. Then I got following error. [ERROR] Failed to resolve dependency of 'ClassLibrary1.dll'. Exception: dnlib.DotNet.AssemblyResolveException: Could not resolve assembly: System.Console, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 在 dnlib.DotNet.Extensions.ResolveThrow(IAssemblyResolver self, IAssembly assembly, ModuleDef sourceModule) 位置 C:\projects\modphuserex\dnlib\src\DotNet\IAssemblyResolver.cs:行号 113 在 Confuser.Core.ConfuserEngine.Inspection(ConfuserContext context) 位置 C:\projects\modphuserex\Confuser.Core\ConfuserEngine.cs:行号 264 Failed at 8:37 PM, 0:00 elapsed.

I obfuscated with the assemblies with 'dotnet publish -c Release'.

Dev-SlimGIS avatar Mar 14 '17 12:03 Dev-SlimGIS

I have not yet tested ModPhuserEx with netstandard libraries; I have currently only tested with netcoreapp1.1.

I will look into this.

0xFireball avatar Mar 14 '17 15:03 0xFireball

The source of the problem is that the .NET Core SDKs do not have System.Console installed as a reference assembly in the SDK path: if you see my .net core instructions.

For now the SDK includes a System.Console.dll in net46, so you can work around this by adding an additional probePath to C:\Program Files\dotnet\sdk\1.0.0-rc4-004771\Sdks\Microsoft.NET.Sdk\tools\net46.

0xFireball avatar Mar 14 '17 15:03 0xFireball

@Dev-SlimGIS any update on this? Is your problem solved by the fix I suggested?

0xFireball avatar Apr 28 '17 05:04 0xFireball

@0xFireball It works for me.

But unfortunately, I got the following error when trying to run my .NET core console app.

Unhandled Exception: System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> System.MethodAccessException: Attempt by method '<Module>.?????????????????????????????????????????()' to access method 'System.AppDomain.add_AssemblyResolve(System.ResolveEventHandler)' failed. at ?????????????????????????????????????????() at .cctor() --- End of inner exception stack trace ---

After removing the rename rule, the error becomes:

Unhandled Exception: System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> System.MethodAccessException: Attempt by method '<Module>.?????????????????????????????????????????()' to access method 'System.AppDomain.add_AssemblyResolve(System.ResolveEventHandler)' failed. at ?????????????????????????????????????????() at .cctor() --- End of inner exception stack trace --- at MyApp.Program.Main()

I have found the cause: type names got via reflection is used in the program. But it leads to another problem: #9 .

zwcloud avatar Aug 23 '17 12:08 zwcloud