Bad IL Format

RP1210 Development Package and RP1210 Connectivity to PEAK CAN Interfaces
Locked
dcsheive
Posts: 2
Joined: Mon 24. Mar 2025, 16:32

Bad IL Format

Post by dcsheive » Tue 25. Mar 2025, 13:00

I am trying to create a C# WPF .NET Core 8 application that will load the RP1210 dlls dynamically. When using Assembly.LoadFrom(path), I get this error. Bad IL format. The format of the file 'C:\Windows\System32\PEAKRP32.dll' is invalid. I've seen two things, that I may have to run the application in x86 or x64, but neither this nor using the dll in the SysWOW64 directory changes this. I've seen that it may also be due to trying to use a .NET framework compiled DLL in a .NET Core project will not work. Is what I'm attempting to do possible or am I just doing something wrong? There doesn't appear to be any C# documentation for your RP1210 dll unlike everything else.

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: Bad IL Format

Post by K.Wagner » Wed 26. Mar 2025, 08:08

Hello,

the error you get is right. Note that te PCAN-RP1210 is a native, in C++ written, Windows library. It is not an assembly. If you want to use this in an .NET environment, then you need to create a wrapper for it (keyword: marshaling). The norm specifies the header file for C/C++ within the RP1210 documentation. We also offer this header file in the RP1210 package. You can download this package using this link.

In summary, you need to "port" the C/C++ heder file into a C# header file for using it in .NET projects.

Hope to have helped you.
Best regards,
Keneth

dcsheive
Posts: 2
Joined: Mon 24. Mar 2025, 16:32

Re: Bad IL Format

Post by dcsheive » Thu 27. Mar 2025, 12:45

Thank you for your response.

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: Bad IL Format

Post by K.Wagner » Fri 28. Mar 2025, 10:57

Hello,

you are welcome.
Best regards,
Keneth

Locked