简体   繁体   中英

Testand - Use of a C# DLL using a C# Wrapper using a C DLL

There is a C-Funktion which I use as a DLL. The function is exported by

__declspec(dllexport) uint8_t *SomeFunction(uint8_t *a);

In the respective header file.

The wrapper imports the function with

[DllImport("SomeCFunction.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SomeFunction")]
private static extern IntPtr SomeFunction(Byte[] array1);

The wrapper has a method with which contains the call of that function

public unsafe Byte[] SomeFunction(Byte[] array1, Byte[] array2)
{
    IntPtr parray2 = CalculateKeyFromSeed(array1);

}

Now I get the Error when executing the step in TestStand:

An exception occurred inside the call to .NET member 'SomeFunction': System.BadImageFormatException: Es wurde versucht, eine Datei mit einem falschen Format zu laden. (Ausnahme von HRESULT: 0x8007000B) bei SomeFunctionWrapperNameSpace.WrapperClass.SomeFunction(Byte[] array1) bei WrapperNameSpace.WrapperClass.SomeFunction(Byte[] array1, Byte[] array2) in SomeFunctionWrapper.cs:Zeile 33. bei SomeFunction(Byte[] array1, Byte[] array2) in SomeFunction.cs:Zeile 39.

Some idea how I get TestStand accepting this DLL?

BadImageFormat normally means there is a mismatch in the bitness of one of the parts.

These need to match, you have 3 parts to check

  • Is the C dll 64-bit?
  • Is the C# dll 64-bit? (AnyCPU should be OK here AFAIK)
  • Is the TestStand process 64-bit?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM