我正在尝试使用 C# 中的 Powerbuilder ORCA Api,但我在编组方面遇到了一些问题。这是 ORCA Api 的 C 头文件,我正在尝试实现 PBORCA_SccGetConnectProperties 函数,该函数需要 pborca_scc 结构。这是我的定义:
[DllImport(OrcaModule, CharSet = CharSet.Auto)]
internal static extern int PBORCA_SccGetConnectProperties(IntPtr ORCASession,
[MarshalAs(UnmanagedType.LPWStr)] string Workspace,
ref OrcaSccInfo SCCInfo);
public delegate int TextOutDelegate(
[MarshalAs(UnmanagedType.LPWStr)] string data,
int userData);
public delegate void BuildProjectDelegate(
OrcaBuildError BuildError,
IntPtr userData);
[StructLayout(LayoutKind.Sequential)]
public sealed class OrcaSccInfo
{
internal IntPtr Wnd = IntPtr.Zero;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
internal string ProviderName = null;
internal int Capabilities = 0;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
internal string UserID = null;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 301)]
internal string Project = null;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 301)]
internal string LocalProjPath = null;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 301)]
internal string AuxPath = null;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 301)]
internal string LogFile = null;
internal TextOutDelegate SccMsgHandler = null;
internal BuildProjectDelegate OrcaMsgHandler = null;
internal int lCommentLen = 0;
internal int lAppend = 0;
internal IntPtr CommBlk = IntPtr.Zero;
internal int DeleteTempFiles = 0;
}
像这样调用函数时:
ret = Interop.PBORCA_SccGetConnectProperties(session.Handle,
@"D:\PB11-test\test.pbw",
ref scc);
我收到一个 FatalExecutionEngineError 消息,它可能是由于编组错误。我一遍又一遍地重复这个问题,似乎找不到我在编组函数、结构或委托的方式上犯的错误。