1
Vote

Generic Method Failure: dnlib.DotNet.TypeResolveException: Could not resolve type:

description

Hi,

I found this error when obfuscating some code. I managed to produce the exact scenario that causes this error.

I built the library and tried to debug it. The error is the trd is null after tdr = tdr.ScopeType; in ICodedToken, method public static TypeDef ResolveTypeDefThrow(this ITypeDefOrRef tdr).

Unfortunately I don't have much more to add. Hopefully you will be able to reproduce.

Thanks for the great library.

regards
Michael

There is an exception when I include the following code in my utility class:
internal static class Utility
{

    public static int RowCountFails<T>(this T[,] obj)
    {
        return obj.GetUpperBound(0) - obj.GetLowerBound(0) + 1;
    }


    public static T[,] TransposeFails<T>(this T[,] input)
    {
        var newArray = new T[input.ColCountFails(), input.RowCountFails()];
        for (var col = 0; col < input.ColCountFails(); col++)
            for (var row = 0; row < input.RowCountFails(); row++)
                newArray[col, row] = input[row, col];
        return newArray;
    }

    public static object[,] Transpose(this object[,] input)
    {
        var newArray = new object[input.ColCount(), input.RowCount()];
        for (var col = 0; col < input.ColCount(); col++)
            for (var row = 0; row < input.RowCount(); row++)
                newArray[col, row] = input[row, col];
        return newArray;
    }
}

The exception is:

[DEBUG] Executing 'Name analysis' phase...
[DEBUG] Building VTables & identifier list...
[DEBUG] Analyzing...
[ERROR] Failed to resolve a type, check if all dependencies are of correct versi
on.
Exception: dnlib.DotNet.TypeResolveException: Could not resolve type:
at dnlib.DotNet.Extensions.ResolveTypeDefThrow(ITypeDefOrRef tdr) in c:\data\
docs\software\dw\dwxl\apps\ConfuserEx-master\dnlib\src\DotNet\ICodedToken.cs:lin
e 512
at Confuser.Renamer.Analyzers.InterReferenceAnalyzer.Analyze(ConfuserContext
context, INameService service, IDnlibDef def) in c:\data\docs\software\dw\dwxl\a
pps\ConfuserEx-master\Confuser.Renamer\Analyzers\InterReferenceAnalyzer.cs:line
25
at Confuser.Renamer.AnalyzePhase.Analyze(NameService service, ConfuserContext
context, ProtectionParameters parameters, IDnlibDef def, Boolean runAnalyzer) i
n c:\data\docs\software\dw\dwxl\apps\ConfuserEx-master\Confuser.Renamer\AnalyzeP
hase.cs:line 77

comments