0

有一个 C-Funktion 我用作 DLL。该函数由

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

在各自的头文件中。

包装器导入函数

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

包装器有一个方法,其中包含对该函数的调用

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

}

现在在 TestStand 中执行步骤时出现错误:

在调用 .NET 成员“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[] SomeFunction.cs:Zeile 39 中的数组 1,字节 [] 数组 2)。

一些想法如何让 TestStand 接受这个 DLL?

4

1 回答 1

1

BadImageFormat 通常意味着其中一个部分的位数不匹配。

这些需要匹配,您需要检查 3 个部分

  • C dll 是 64 位的吗?
  • C# dll 是 64 位的吗?(AnyCPU 在这里应该没问题 AFAIK)
  • TestStand 进程是 64 位的吗?
于 2015-10-09T09:17:11.017 回答