22

I'm embedding required assemblies to my project and resolving them on runtime with AppDomain.CurrentDomain.AssemblyResolve event.

All works okay except irrKlang's .net4-wrapper, which throws an exception if i try so;

System.IO.FileLoadException: Attempt to load an unverifiable executable with fixups (IAT with more than 2 sections or a TLS section.) (Exception from HRESULT: 0x80131019)
   at System.Reflection.RuntimeAssembly.nLoadImage(Byte[] rawAssembly, Byte[] rawSymbolStore, Evidence evidence, StackCrawlMark& stackMark, Boolean fIntrospection, SecurityContextSource securityContextSource)
   at System.Reflection.Assembly.Load(Byte[] rawAssembly)
   at xyz.Utility.Helpers.AssemblyManager.Resolver(Object sender, ResolveEventArgs args) in C:\Users\shalafi\Desktop\xyz\trunk\xyz\Utility\Helpers\AssemblyManager.cs:line 55
   at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)

Basicly i suspect of CLR not being able to load mixed mode assemblies with Assembly.Load(byte[]) though i'm not sure.

I was not able to find anything related to the exception message;

Attempt to load an unverifiable executable with fixups (IAT with more than 2 sections or a TLS section.)

Help appreciated.

Community
  • 1
  • 1
HuseyinUslu
  • 4,094
  • 5
  • 33
  • 50
  • 1
    seems this there's no work-around for this: http://books.google.com/books?id=wZoQyVi5f60C&pg=PA150&dq=unverifiable+executable+with+fixups&hl=en&ei=xptaTdzXEMafOpWjjP8L&sa=X&oi=book_result&ct=result&resnum=1&ved=0CCYQ6AEwAA#v=onepage&q=unverifiable%20executable%20with%20fixups&f=false – HuseyinUslu Feb 15 '11 at 15:29
  • 4
    Solution is that you change C++ assembly from EXE to DLL! There is probably some linker optimization during EXE loading which is not supported by CLR loader. See: http://zamboch.blogspot.com/2007/11/fileloadexception-when-loading-ccli.html – zproxy Mar 04 '11 at 08:12
  • 2
    c++ assembly i use is already a dll.. – HuseyinUslu Mar 04 '11 at 08:49
  • related: http://stackoverflow.com/questions/2945080/how-do-i-dynamically-load-raw-assemblies-that-contains-unmanaged-codebypassing – Ruben Bartelink Feb 12 '13 at 09:35
  • Thank you HuseyinUslu for posting that book page. Led me to change the CLR mode from normal to pure. resolved my issue! – Hardycore Mar 12 '15 at 16:04
  • 1
    I had the same issue, I just changed projects to same platform and it worked. – Mr. Blond Jul 30 '16 at 12:21

2 Answers2

5

EDIT : The references i posted are not valid anymore, because of outdated external links. Please refer here. How do I dynamically load raw assemblies that contains unmanaged code?(bypassing 'Unverifiable code failed policy check' exception)

Soundararajan
  • 2,000
  • 21
  • 23
  • 2
    I found that you can see part of it at the related question http://stackoverflow.com/questions/2945080/how-do-i-dynamically-load-raw-assemblies-that-contains-unmanaged-codebypassing – porges Mar 14 '13 at 18:44
  • Microsoft Connect stopped, please fix link @Soundararajan – Noah Heber Feb 16 '18 at 06:20
  • @NoahHeber The link is not available and nor the Microsoft Collaborate website has setup the link. After reviewing the post that porges posted has valuable information about the error. – Soundararajan Feb 17 '18 at 18:08
0

Just in case anyone else is having my version of this problem, here's how I fixed it:

  • Create a new project with a different name
  • Copy all of your files into the new project (including code)
  • Add references to all the files necessary to compile without errors

I really must have messed something up with my references/resources. I was getting this error when trying to load any external .dll from my program.

Micah Vertal
  • 564
  • 1
  • 7
  • 16