日期:2014-05-17  浏览次数:20831 次

C#调用C++ Builder写的OCX
对方使用了Borland C++ Builder写了一个ocx控件,在MFC,vb,delphi下都可以正常引用控件,但是在C#下面则出现错误,以前没有引用过C++ Builder的东西,不知道到底是什么问题;

添加ocx控件倒是没有什么问题,但是在拖拉空间到界面上,或者动态创建空间的时候度出现错误:

pClientSite == 0 || m_spClientSite == 0 @ c:\program file\broland\cbuilder6\include\alt\atlctl.h/906
Press [Y]es to terminate,[N]o to continue and [C]ancel to Debug

Yes后则报外部控件异常,错误信息没什么用
************* 异常文本 **************
System.Runtime.InteropServices.SEHException: 外部组件发生异常。
   在 System.Windows.Forms.UnsafeNativeMethods.IOleObject.SetClientSite(IOleClientSite pClientSite)
   在 System.Windows.Forms.AxHost.SlowActivate()
   在 System.Windows.Forms.AxHost.TransitionUpTo(Int32 state)
   在 System.Windows.Forms.AxHost.CreateHandle()
   在 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   在 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   在 System.Windows.Forms.Control.CreateControl()
   在 System.Windows.Forms.Control.WmShowWindow(Message& m)
   在 System.Windows.Forms.Control.WndProc(Message& m)
   在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   在 System.Windows.Forms.ContainerControl.WndProc(Message& m)
   在 System.Windows.Forms.Form.WmShowWindow(Message& m)
   在 System.Windows.Forms.Form.WndProc(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

不知道要如何处理才能正常引用控件。。。。。。。

------解决方案--------------------
如果没什么机密,楼主,你发给我试试:
sdl2002lyx@163.com
------解决方案--------------------
这个提示是控件本身程序出错了,你可以用C++Buder的源程序调试一下。而且我觉得用其他语言调用,一样会出这个错误。你是在同一台电脑上试验的吗?
------解决方案--------------------