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

Could not resolve assembly: System.Web.HttpUtility #335

Closed
jj2hh2hasdf opened this issue Mar 13, 2021 · 13 comments
Closed

Could not resolve assembly: System.Web.HttpUtility #335

jj2hh2hasdf opened this issue Mar 13, 2021 · 13 comments
Labels
feedback-required This issue can't be processed further until additional information are provided.

Comments

@jj2hh2hasdf
Copy link

jj2hh2hasdf commented Mar 13, 2021

Error from confuserex:
[ERROR] Failed to resolve dependency of 'a.dll'. Exception: dnlib.DotNet.AssemblyResolveException: Could not resolve assembly: System.Web.HttpUtility, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 at dnlib.DotNet.Extensions.ResolveThrow(IAssemblyResolver self, IAssembly assembly, ModuleDef sourceModule) at Confuser.Core.ConfuserEngine.Inspection(ConfuserContext context) Failed at 01:21, 0:02 elapsed.

  • ConfuserEx Version: 1.6.0-alpha
  • Target Framework: netcoreapp3.1
  • Operating System: Windows 10

my project file:

a.txt

@jj2hh2hasdf jj2hh2hasdf added potential-bug Something does not seem to be working triage This issue needs some initial analysis. labels Mar 13, 2021
@mkaring
Copy link
Owner

mkaring commented Mar 13, 2021

.NET Core 3.1 isn't working very well with ConfuserEx is general. I'm referring to #302

In your case you can try to add the path to .NET Core 3.1 as probe path and see how far that get's you.
So try adding

<probePath>C:\Program Files\dotnet\sdk\3.1.407</probePath>

If any assemblies are resolved with the wrong version, you may need to add those assemblies as external references.

@mkaring mkaring added feedback-required This issue can't be processed further until additional information are provided. and removed potential-bug Something does not seem to be working triage This issue needs some initial analysis. labels Mar 13, 2021
@jj2hh2hasdf
Copy link
Author

jj2hh2hasdf commented Mar 13, 2021

Where should I put C:\Program Files\dotnet\sdk\3.1.407 in the project file ?

My path is C:\Program Files\dotnet\sdk\5.0.100

@mkaring
Copy link
Owner

mkaring commented Mar 13, 2021

At the very bottom inside the <project> tag. Alternatively you can add the path using the ConfuserEx graphical interface.
According to your first issue, you are targeting .NET Core 3.1, so the version number in your path should start with 3.1.

@jj2hh2hasdf
Copy link
Author

jj2hh2hasdf commented Mar 13, 2021

I get the an error when I put it in

Error MSB4067 The element probePath beneath element is unrecognized.
a.txt

EDIT:
Changed the version to 5.0 and tried protecting getting a new error now:

[DEBUG] Creating global .cctors... [DEBUG] Executing 'Name analysis' phase... [DEBUG] Building VTables & identifier list... [ERROR] Failed to resolve a type, check if all dependencies are present in the correct version. Exception: dnlib.DotNet.TypeResolveException: Could not resolve type: System.Runtime.CompilerServices.IAsyncStateMachine (System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) at dnlib.DotNet.TypeRef.ResolveThrow(ModuleDef sourceModule) at Confuser.Renamer.VTableStorage.GetVTable(ITypeDefOrRef type) at Confuser.Renamer.VTable.ConstructVTable(TypeDef typeDef, VTableStorage storage) at Confuser.Renamer.VTableStorage.GetOrConstruct(TypeDef type) at Confuser.Renamer.AnalyzePhase.Execute(ConfuserContext context, ProtectionParameters parameters) at Confuser.Core.ProtectionPipeline.ExecuteStage(PipelineStage stage, Action1 func, Func1 targets, ConfuserContext context) at Confuser.Core.ConfuserEngine.RunPipeline(ProtectionPipeline pipeline, ConfuserContext context) at Confuser.Core.ConfuserEngine.RunInternal(ConfuserParameters parameters, CancellationToken token) [ERROR] ---BEGIN DEBUG INFO--- [ERROR] Installed Framework Versions: [ERROR] v2.0.50727 2.0.50727.4927 [ERROR] v3.0 3.0.30729.4926 [ERROR] v3.5 3.5.30729.4926 [ERROR] v4 [ERROR] Client 4.8.04084 [ERROR] Full 4.8.04084 [ERROR] v4.0 [ERROR] Client 4.0.0.0 [ERROR] v4.5 528372 [ERROR] [ERROR] Cached assemblies: [ERROR] a, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null (B:\Repos\a\a\bin\Release\netcoreapp5.0\ref\a.dll) [ERROR] System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a [ERROR] System.Collections, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a [ERROR] System.Linq.Expressions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a [ERROR] System.Threading, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a [ERROR] System.Net.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a [ERROR] Yove.Proxy, Version=1.1.1.0, Culture=neutral, PublicKeyToken=null [ERROR] BouncyCastle.Crypto, Version=1.8.9.0, Culture=neutral, PublicKeyToken=0e99375e54769942 (B:\Repos\a\a\bin\Release\netcoreapp5.0\BouncyCastle.Crypto.dll) [ERROR] mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 [ERROR] System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 [ERROR] System.CodeDom, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 (B:\Repos\a\a\bin\Release\netcoreapp5.0\System.CodeDom.dll) [ERROR] netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 [ERROR] System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (B:\Repos\a\a\bin\Release\netcoreapp5.0\System.Management.dll) [ERROR] netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 [ERROR] System.CodeDom, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 [ERROR] Yove.Proxy, Version=1.1.1.0, Culture=neutral, PublicKeyToken=null (B:\Repos\a\a\bin\Release\netcoreapp5.0\Yove.Proxy.dll) [ERROR] netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 [ERROR] Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed (B:\Repos\a\a\bin\Release\netcoreapp5.0\Newtonsoft.Json.dll) [ERROR] netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 Failed at 11:47, 0:01 elapsed.

@mkaring
Copy link
Owner

mkaring commented Mar 13, 2021

You have to put the probe path into the *.crproj file, not into the *.csproj. The one used by ConfuserEx is the correct one.

netcoreapp5.0 is not a legal target framework. It's net5.0. In any case this isn't going to work very well either. Try to stick to 3.1, or better 2.1. Anything later than 2.1 does not work to my knowledge. At least I don't know of anyone who got it working. You can try, but it's unlikely.

ConfuserEx currently only work properly when using the .NET Framework.

@jj2hh2hasdf
Copy link
Author

"You have to put the probe path into the *.crproj file, not into the *.csproj" dont understand ?

And changed it 2.1 and:

[ERROR] Failed to resolve dependency of 'a.dll'. Exception: dnlib.DotNet.AssemblyResolveException: Could not resolve assembly: System.Web.HttpUtility, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 at dnlib.DotNet.Extensions.ResolveThrow(IAssemblyResolver self, IAssembly assembly, ModuleDef sourceModule) at Confuser.Core.ConfuserEngine.Inspection(ConfuserContext context) Failed at 13:42, 0:01 elapsed.

@mkaring
Copy link
Owner

mkaring commented Mar 13, 2021

If you open an assembly in ConfuserEx, you can save the project in a *.crproj file. This file contains the configuration for ConfuserEx. This is the file where the probe path needs to be added.

@jj2hh2hasdf
Copy link
Author

Like this ? vv, And it still gives the same error :(

a.txt

@mkaring
Copy link
Owner

mkaring commented Mar 13, 2021

The file seems okay. Where is System.Web.HttpUtility coming from. It's not part of the .NET Core SDK. I just checked this. Also you did not list it in the modules, so I'm guessing it's missing from your output as well?

It something like

  <module path="a\bin\Release\netcoreapp2.1\System.Web.HttpUtility.dll" external="true" />

missing from your project, as in: Is this file present in your output directory?

Also I advice to mark the assemblies you don't want obfuscated as external:

<project outputDir="B:\Repos\a\Confused" baseDir="B:\Repos\a" xmlns="http://confuser.codeplex.com">
  <rule pattern="true" preset="maximum" inherit="false" />
  <module path="a\bin\Release\netcoreapp2.1\a.dll" />
  <module path="a\bin\Release\netcoreapp2.1\Newtonsoft.Json.dll" external="true" />
  <module path="a\bin\Release\netcoreapp2.1\System.CodeDom.dll" external="true" />
  <module path="a\bin\Release\netcoreapp2.1\System.Management.dll" external="true" />
  <module path="a\bin\Release\netcoreapp2.1\System.Security.AccessControl.dll" external="true" />
  <module path="a\bin\Release\netcoreapp2.1\System.Security.Principal.Windows.dll" external="true" />
  <module path="a\bin\Release\netcoreapp2.1\Yove.Proxy.dll" external="true" />
  <module path="a\bin\Release\netcoreapp2.1\Microsoft.Win32.Registry.dll" external="true" />
  <module path="a\bin\Release\netcoreapp2.1\BouncyCastle.Crypto.dll" external="true" />
  <probePath>C:\Program Files\dotnet\sdk\2.1.814</probePath>
</project>

As they are located in the same directory as your main assembly, you could also remove them from the file, in that case they won't get copied to the output directory mind you.

Long story short: ConfuserEx can't resolve the assembly. That is the problem. This means you either have to declare it as external <module> or you have to set the <probePath> to where this file is located.

@jj2hh2hasdf
Copy link
Author

Ok, I didn't really need system.web so I removed it (needed it to url enocde a string) either way

Now when I try and protect it give a new error

[INFO] Confuser.Core 1.6.0-alpha Copyright © 2014 Ki, 2018 - 2021 Martin Karing [INFO] Running on Microsoft Windows NT 6.2.9200.0, .NET Framework v4.0.30319.42000, 64 bits [DEBUG] Discovering plugins... [INFO] Discovered 13 protections, 1 packers. [DEBUG] Resolving component dependency... [INFO] Loading input modules... [INFO] Loading 'a\bin\Release\netcoreapp2.1\a.dll'... [INFO] Initializing... [DEBUG] Building pipeline... [DEBUG] Executing 'Type scanner' phase... [INFO] Resolving dependencies... [DEBUG] Checking Strong Name... [DEBUG] Creating global .cctors... [DEBUG] Executing 'Name analysis' phase... [DEBUG] Building VTables & identifier list... [ERROR] Failed to resolve a type, check if all dependencies are present in the correct version. Exception: dnlib.DotNet.TypeResolveException: Could not resolve type: System.Runtime.CompilerServices.IAsyncStateMachine (System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) at dnlib.DotNet.TypeRef.ResolveThrow(ModuleDef sourceModule) at Confuser.Renamer.VTableStorage.GetVTable(ITypeDefOrRef type) at Confuser.Renamer.VTable.ConstructVTable(TypeDef typeDef, VTableStorage storage) at Confuser.Renamer.VTableStorage.GetOrConstruct(TypeDef type) at Confuser.Renamer.AnalyzePhase.Execute(ConfuserContext context, ProtectionParameters parameters) at Confuser.Core.ProtectionPipeline.ExecuteStage(PipelineStage stage, Action1 func, Func`1 targets, ConfuserContext context)
at Confuser.Core.ConfuserEngine.RunPipeline(ProtectionPipeline pipeline, ConfuserContext context)
at Confuser.Core.ConfuserEngine.RunInternal(ConfuserParameters parameters, CancellationToken token)
[ERROR] ---BEGIN DEBUG INFO---
[ERROR] Installed Framework Versions:
[ERROR] v2.0.50727 2.0.50727.4927
[ERROR] v3.0 3.0.30729.4926
[ERROR] v3.5 3.5.30729.4926
[ERROR] v4
[ERROR] Client 4.8.04084
[ERROR] Full 4.8.04084
[ERROR] v4.0
[ERROR] Client 4.0.0.0
[ERROR] v4.5 528372
[ERROR]
[ERROR] Cached assemblies:
[ERROR] a, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null (B:\Repos\a\a\bin\Release\netcoreapp2.1\a.dll)
[ERROR] System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] System.Net.Sockets, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] System.Net.Primitives, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] System.Security.Cryptography.Algorithms, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] System.Security.Cryptography.Primitives, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] System.Runtime.Extensions, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] BouncyCastle.Crypto, Version=1.8.9.0, Culture=neutral, PublicKeyToken=0e99375e54769942
[ERROR] System.Threading.Tasks, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] System.Diagnostics.Debug, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] System.Threading, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] System.Collections, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] System.Linq.Expressions, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] System.Net.Http, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] Yove.Proxy, Version=1.1.1.0, Culture=neutral, PublicKeyToken=null
[ERROR] System.Console, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] System.Security.Cryptography.Csp, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] System.Linq, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] System.IO.FileSystem, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] System.Threading.Thread, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
[ERROR] Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
[ERROR] netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
[ERROR] System.CodeDom, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
[ERROR] netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
[ERROR] System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
[ERROR] System.CodeDom, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
[ERROR] System.Security.AccessControl, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
[ERROR] System.Security.Principal.Windows, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] System.Security.Principal.Windows, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
[ERROR] Yove.Proxy, Version=1.1.1.0, Culture=neutral, PublicKeyToken=null
[ERROR] netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
[ERROR] Microsoft.Win32.Registry, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
[ERROR] System.Security.AccessControl, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] System.Security.Principal.Windows, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR] BouncyCastle.Crypto, Version=1.8.9.0, Culture=neutral, PublicKeyToken=0e99375e54769942
[ERROR] mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
[ERROR] System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Failed at 14:50, 0:00 elapsed.

`

@mkaring
Copy link
Owner

mkaring commented Mar 14, 2021

It's telling you the external modules you need to define by hand to get it working one by one. The next one is System.Runtime.

@mkaring mkaring closed this as completed Mar 14, 2021
@mkaring
Copy link
Owner

mkaring commented Mar 14, 2021

The issue was worked around by switching to .NET Framework 4.8.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feedback-required This issue can't be processed further until additional information are provided.
Projects
None yet
Development

No branches or pull requests

2 participants