Use Mono.cecil to save the Times "Failed to resolve assembly: ' xxxxxx, Version=xxxxx,culture=xxxxx," for the Il modification of the target. NET DLL program. Publickeytoken=xxxxxxx ' "Exception.
Debug with Dnspy, originally because the modified target DLL and its own program is not the same directory, when it is necessary to use the DLL referenced by the target DLL when the Mono.cecil only in their own directory for the search match,
If the corresponding DLL file is not found, the above exception information will be reported.
There are two ways to resolve this:
The first one: simply copy the corresponding DLL to the directory where the program itself is located.
The second one: Add the target directory that mono.cecil can search in the program.
Defaultassemblyresolver resolver = new Defaultassemblyresolver (); Resolver. Addsearchdirectory (info. DirectoryName); Add target directory readerparameters parameters = new Readerparameters () { assemblyresolver = resolver,// The object of the target directory will be added as a parameter to assemblyresolver Readsymbols = False, }; Assemblydefinition asm = assemblydefinition.readassembly (file, parameters); Use the above parameters to complete the target directory of the specified and search
Mono.cecil Modify the target. NET IL code to save the Times exception handling.