0
votes

When trying to obfuscate a UWP (WinRT) AnyCPU assembly using CryptoObfuscator, the following error messages are observed:

1.) When merging in LogicNP.CryptoLicensing.WinRT.dll (a WinRT assembly) into a UWP DLL:

Error occurred while obfuscation: - .Net framework version type of the licensing assembly (Silverlight) does not match the version type of the obfuscating assembly (Normal).

enter image description here

2.) When merging of the licensing assembly is ignored:

Error occurred while obfuscation: System.IO.FileNotFoundException - System.IO.FileNotFoundException: could not result: System.Runtime, Version=4.0.20.0, Culture=neutral... Specify the path where this assembly resides using 'Search Directories'

Has anyone successfully used CryptoObfuscator (which is advertised as working on any .NET assembly) successfully?

enter image description here

2
Not sure if this helps, but UWP does not run in AnyCPU mode. You have to explicitly select x86, x64, or ARM. Also, UWP uses .NetNative. Have a look at that to see if you even need to obfuscate.Laith
Thanks @Laith, the class libraries I'm trying to obfuscate are UWP Class Libraries and are compiled as Any CPU. The exe is not obfuscated. Is that the case for class libraries too (cannot be Any CPU?)Dr. Andrew Burnett-Thompson
CryptoObfuscator (which is advertised as working on any .NET assembly) => for working with UWP, Microsoft recommends using Dotfuscator. In regards of the class libraries: I think it's an issue with the project template. @Laith is correct that everything will be compiled into x86, x64 and ARM. I'm not sure why the project template creates an Any CPU configuration for universal class libraries.Herdo
@Herdo if you open a Visual Studio 2015, or 2017 project, go to File -> New -> Universal Windows Class Library, then right click the project and go to Build, you will see Platform Target 'Any CPU' selected as default.Dr. Andrew Burnett-Thompson
Had the same problem. Solution for the can not find dependent assembly was on .NET standard 2.0 to add the following to the property group in the csproj file: <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>Guido Leenders

2 Answers

2
votes

There are in fact two issues to take into account when using CryptObfuscator in this scenario:

To obfuscate for other .NET versions, the following must be added to each relevant csproj in addition to setting the target framework to :

<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

This resolves most can not find file issues when obfuscating.

For System.Runtime, you will need to download and open the NuGet package of System.Runtime. In the lib folder you will find some nice hacks that depend on the CLR in use and glue the rest of your .NET assemblies together with the CLR, such as using forwarded types for .NET 4.7. But in the ref folder such as for netstandard1.5 you will find a System.Runtime.dll. Copy that one manually to the output folder or a location where CryptoObfuscator will search.

You can also put it in another folder, and specify in CryptoObfuscator a search directory using Project Properties or in XML:

<SearchDirectories>
  <SearchDirectory Path="PATH" />
</SearchDirectories>
1
votes

Try Download from nuget "Microsoft.NETCore.UniversalWindowsPlatform" and copy "System.Runtime.dll" downloaded from nuget to CryptoObfuscator folder.