ActiveX控件调用JS方法出错
我是按照http://blog.csdn.net/sabty/article/details/4165342
这个地址的方法进行试验
但是出现的问题是
在 oleClientSite2.GetContainer(out pObj); 这一句报错
报错的内容是:
未处理 System.NullReferenceException
HResult=-2147467261
Message=未将对象引用设置到对象的实例。
Source=HelloDaniel
StackTrace:
在 HelloDaniel.HelloDanielActiveX.CallJavaScript(String param) 位置 C:\Users\xiaohe\Desktop\HID USB\HelloDaniel\HelloDaniel\HelloDaniel\HelloDanielActiveX.cs:行号 158
在 HelloDaniel.HelloDanielActiveX.button1_Click(Object sender, EventArgs e) 位置 C:\Users\xiaohe\Desktop\HID USB\HelloDaniel\HelloDaniel\HelloDaniel\HelloDanielActiveX.cs:行号 182
在 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(IntPtr 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)
在 Microsoft.VisualStudio.Tools.UserControlTestContainer.Main(String[] args)
InnerException:
其中:
第182行是 CallJavaScript(this.label2.Text);
158行是 oleClientSite2.GetContainer(out pObj);