Net load dll from resource matlab

System Requirements: Windows 8, Windows 7, Windows 8.1


When I try to load in Matlab my. NET assembly foo.dll by typing: asm = NET.add Assembly fullpath\foo.dll I get the following error: Could not load file or assembly ' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. Source: mscorlib Help Link: I've Matlab R2010a and I tried to build the assembly both for. NET framework 4.0 and. NET framework 3.0 with no success. EDIT I did several tests and now maybe I've partly discovered the problem. In the above example I was trying to add a private assembly by giving the full path. I then remembered to have also previously registered the same assembly (targeted for. NET 4.0) in the GAC (through the gacutil /i foo.dll command). Hence I removed the assembly from the GAC (gacutil /u foo) and now at least I'm able to add the private assembly targeted for. NET 3.0 but still not if I want to target. NET 4.0. I presume that before, when I was trying to add a private assembly for. NET 3.0, Matlab was still trying to add the assembly for. NET 4.0 installed in the GAC, because of some conflict. However, I still do not understand why I cannot use. NET 4.0.
I'm calling functions from a 32-bit unmanaged DLL on a 64-bit system. What I get is: Bad Image Format Exception: An attempt was made to load a program with an incorrect format. ( Exception from HRESULT: 0x8007000 B) At first, I had my projects set to the Any CPU platform, so I changed them both to x86, but this error is still occurring. That's really the only fix I know for this. The DLLs aren't corrupt or anything, because I can use them with other programs (that I don't have the source to). I thought that perhaps it wasn't finding a dependency, but I checked and they're all there. Plus, wouldn't it throw a Dll Not Found Exception in that case? What else can I do? And before you say Use a 64-bit unmanaged DLL instead, let me point out that there isn't one.