guitar80
guitar80

Reputation: 726

Bad IL Format Error: .NET Dynamic Assembly

When calling Assembly.Load(), I get a BadFormatException in my project with a message:

Bad IL Format Error.

I am using raspberry-sharp-Io and I am trying to send the DLLs across the network and load them. I have done this in the past successfully by reading the 'bin' folder DLL files and transmitting them for loading. Although, I can add a reference at compile time just fine, the runtime version won't load even locally (much less over a network).

Does anyone know what could be causing this?

Specs: My projects are 4.5.2 and raspberry-sharp-Io is .NET 4.0. I am running on Windows 10 for my tests and currently I am running everything locally to avoid network related errors. Raspberry-sharp-Io has a GitHub page as well as a NuGet package. My running application is a XAML project.

I have simplified it to the following for testing to eliminate alternative bugs:

byte[] raw = File.ReadAllBytes(dependency.Location);
Assembly.Load(raw); // Exception: "Bad IL Format."

Upvotes: 0

Views: 6146

Answers (1)

guitar80
guitar80

Reputation: 726

Well, I hadn't realized that my target architecture didn't match up. This appears to have solved it now that they are both targeting x86.

Upvotes: 2

Related Questions