System.TypeLoadException error when executing a dll created via c# .net standard library
i compiled an open source code (from github) into a dll, the code changes an executable's icon and id like to use said code in my python project so i compiled it into a dll and loaded it via using clr (a lib which lets you load c#-compiled dll's into python) it loads in without error and gets improrted fine, the issue is upon excuting a method of the class inside the dll i get the exception
i compiled and loaded multiple sample dlls (simple ones) and they ran fine without issue, from what i gather its an import issue of GCHandle which is (if i understand correctly) unmanged memory allocator
im very very newbie with c# and program mostly in python, but i like how fast and verstile c# while prefering the syntax and ease of use of python, hence i use c#- compiled dll's with python, mostly without issues,
any help will be appricated!
6 Replies
i mostly understand what each part of the code does, but no where near a proper c# programmer
Is there an InnerException on the TypeLoadException?
no, this is the entire traceback
My guess would be that the DLL targets a different .NET version to the one it was loaded into, but I've no idea how your python thingy works
will check into this, thanks!
1) Probably reported and resolved https://github.com/pythonnet/pythonnet/issues 2) NativeAOT might be a better option https://github.com/dotnet/samples/blob/main/core/nativeaot/NativeLibrary/README.md