传递给系统调用的数据区域太小。 (异常来自 HRESULT:0x8007007A)

Tord_zhang 2008-06-10 01:43:29
[DllImport("pborc90.dll", CharSet = CharSet.Auto)]
public static extern int PBORCA_CompileEntryImportList(IntPtr hORCASession,
[MarshalAs(UnmanagedType.LPArray,
ArraySubType = UnmanagedType.LPStr)] string[] lpszLibraryName,
[MarshalAs(UnmanagedType.LPArray,
ArraySubType = UnmanagedType.LPStr)] string[] lpszEntryName,
EntryType[] otEntryType,
[MarshalAs(UnmanagedType.LPArray,
ArraySubType = UnmanagedType.LPStr)] string[] lpszComments,
[MarshalAs(UnmanagedType.LPArray,
ArraySubType = UnmanagedType.LPStr)] string[] lpszEntrySyntax,
int[] lEntrySyntaxBuffSize,
int iNumberOfEntries,
[MarshalAs(UnmanagedType.FunctionPtr)] CompileEntryDelegate pCompErrorProc,
IntPtr lpUserData);

protected int CompileEntryImportList(IntPtr hORCASession,
string[] lpszLibraryName,
string[] lpszEntryName,
EntryType[] otEntryType,
string[] lpszComments,
string[] lpszEntrySyntax,
int[] lEntrySyntaxBuffSize,
CompileEntryDelegate pCompErrorProc)
{
int res;
IntPtr lpUserData = IntPtr.Zero;
res = Orca_Inco.PBORCA_CompileEntryImportList(hORCASession,
lpszLibraryName,
lpszEntryName,
otEntryType,
lpszComments,
lpszEntrySyntax,
lEntrySyntaxBuffSize, //这个参数有一个值是22128-->传递给系统调用的数据区域太小。 (异常来自 HRESULT:0x8007007A)
lpszLibraryName.Length,
pCompErrorProc,
lpUserData);
return res;
}

//错误

未处理 System.Runtime.InteropServices.COMException
Message="传递给系统调用的数据区域太小。 (异常来自 HRESULT:0x8007007A)"
Source="PowerBuilderCompile"
ErrorCode=-2147024774
StackTrace:
在 Orca_Inco.PBORCA_CompileEntryImportList(IntPtr hORCASession, String[] lpszLibraryName, String[] lpszEntryName, EntryType[] otEntryType, String[] lpszComments, String[] lpszEntrySyntax, Int32[] lEntrySyntaxBuffSize, Int32 iNumberOfEntries, CompileEntryDelegate pCompErrorProc, IntPtr lpUserData)
在 ORCA_Operate.CompileEntryImportList(IntPtr hORCASession, String[] lpszLibraryName, String[] lpszEntryName, EntryType[] otEntryType, String[] lpszComments, String[] lpszEntrySyntax, Int32[] lEntrySyntaxBuffSize, CompileEntryDelegate pCompErrorProc) 位置 E:\net\PowerBuilderCompile0409xs\PowerBuilderCompile\Orca\ORCA_Operate.cs:行号 97
在 ORCA_Operate.ImportEntrys(String[] pLibNames, String applib, String appname, PBEntrys[] pbentryobjs, String ImportPath) 位置 E:\net\PowerBuilderCompile0409xs\PowerBuilderCompile\Orca\ORCA_Operate.cs:行号 540
在 CompileSubmit.ImportSubmitEntry(VersionInfos& mVersionInfos, String AppID, String VerID, Boolean bSpecify, PBEntrys[] TobeBuildSpecify, String[] TobeGetVssSpecify) 位置 E:\net\PowerBuilderCompile0409xs\PowerBuilderCompile\Compile\CompileSubmit.cs:行号 49
在 PowerBuilderCompile.Compile.CompileSubmitFromDataBase(VersionInfos& mVersionInfos, Boolean bSpecify, PBEntrys[] TobeBuildSpecify, String[] TobeGetVssSpecify) 位置 E:\net\PowerBuilderCompile0409xs\PowerBuilderCompile\Compile.cs:行号 286
在 PowerBuilderCompile.Compile.btnGO_Click(Object sender, EventArgs e) 位置 E:\net\PowerBuilderCompile0409xs\PowerBuilderCompile\Compile.cs:行号 177
在 System.Windows.Forms.Control.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
在 System.Windows.Forms.Button.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 PowerBuilderCompile.Program.Main() 位置 E:\net\PowerBuilderCompile0409xs\PowerBuilderCompile\Program.cs:行号 17
在 System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()

求教高手~
...全文
1149 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
呵逗乐儿 2009-09-08
  • 打赏
  • 举报
回复
c中结构体定义为
typedef struct _CAM_GROUP_INFO
{
int nCamGroupID; //camera group id
char szGroupName[64]; //camera group name
int nServerID; //belong to which server
int state; //MP_CAM_StateXXXX
} CAM_GROUP_INFO;

我现在在c#中定义结构体 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
public struct CAM_GROUP_INFO
{

public int nCamGroupID; //camera group id
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
public char[] szGroupName; //camera group name

public int nServerID; //belong to which server

public int state; //MP_CAM_StateXXXX
};

封装对应有两个方法, //从服务器得到视频组列表
[DllImport(@"E:\dll\playback_dll\debug\playback_dll.dll", EntryPoint = "CCameraMngr_RetrieveCamGroupListFromServer", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int CCameraMngr_RetrieveCamGroupListFromServer([In, Out] int Self, int nServerID, [In, Out] CAM_GROUP_INFO[] pCamGroupList, int iMaxSize);


//释放从服务器得到的视频组列表
[DllImport(@"E:\dll\playback_dll\debug\playback_dll.dll", EntryPoint = "CCameraMngr_FreeCamGroupList", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern void CCameraMngr_FreeCamGroupList([In, Out] int Self, [In, Out] CAM_GROUP_INFO[] pCamGroupList);

像你说的 如果我用CharSet = CharSet.Unicode在c#中像上面这样申明结构体,
则释放不会出错,但是获取CCameraMngr_RetrieveCamGroupListFromServer这个函数
得到的结构体的数据就不对,里面只有nCamGroupID是正确的 其他都是0,字符类型的是乱码,
如果改成ansi申明结构体,则得到数据都是正确的,但释放那个函数会报
“传递给系统调用的数据区域太小。 (异常来自 HRESULT:0x8007007A) ”错误,请求大虾帮忙!!
Tord_zhang 2008-06-10
  • 打赏
  • 举报
回复
搞定继续加分~80
Tord_zhang 2008-06-10
  • 打赏
  • 举报
回复
搞定继续加分~
Tord_zhang 2008-06-10
  • 打赏
  • 举报
回复
搞定继续加分

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧