简体   繁体   English

无法在Vsual WebGui应用程序的客户端上单击按钮时调用ActiveX方法

[英]Not able to call ActiveX method on button click at client side in a Vsual WebGui application

I am creating a project in visual WebGui, On loading of first page i have taken a ActiveXBox and installed it to the system. 我正在可视WebGui中创建一个项目,在加载第一页时,我已将一个ActiveXBox并安装到系统中。

Now I want to access the methods available in the ActiveX control at client side which is already installed in the client machine. 现在,我想访问客户端计算机上已安装的客户端ActiveX控件中可用的方法。 Problem is that the code is executed at server side and the code works for server. 问题是该代码在服务器端执行,并且该代码适用于服务器。

What should i do so that the code will be executed for the client machine. 我应该怎么做才能在客户端计算机上执行代码。

Thanks 谢谢

We can achieve this in this way. 我们可以这样实现。 As the activex control is registered in the com after installing. 由于Activex控件是在安装后在com中注册的。 we can call the methods inside it. 我们可以调用其中的方法。

Type ComType;
object ComObject;
Guid myGuid1 = new Guid("2ABF5C37-ABC3-4600-8115-4F7E6F64C765");
ComType = Type.GetTypeFromCLSID(myGuid1);
ComObject = Activator.CreateInstance(ComType);

object[] args = new object[1];
args[0] = arg1;

ComType.InvokeMember("Your Method Name", BindingFlags.InvokeMethod, null, ComObject, args);

@Amish Kumar, @阿米什·库玛(Amish Kumar),

The code you posted is a server-side code, which for a Visual WebGui web application means, that the code will run at the webserver only, provided the ActiveX control has been installed on the server. 您发布的代码是服务器端代码,对于Visual WebGui Web应用程序,这意味着该代码仅在Web服务器上运行,前提是已在服务器上安装了ActiveX控件。 This may work for you (although not recommended) if you run your web application using your local host as your IIS webserver, but when the webserver is a remote machine, this code will not affect the client. 如果您使用本地主机作为IIS Web服务器运行Web应用程序,这可能对您有用(尽管不建议这样做),但是当Web服务器是远程计算机时,此代码不会影响客户端。

For Visual WebGui Web applications, you have chosen the correct hosting control, ActiveXBox, which will add the ActiveX control to the client's browser. 对于Visual WebGui Web应用程序,您选择了正确的宿主控件ActiveXBox,它将把ActiveX控件添加到客户端的浏览器中。 To control it, you usually set "parameters" on the ActiveXBox control, which will then update/contact the ActiveX control it is hosting. 为了控制它,通常在ActiveXBox控件上设置“参数”,然后将更新/联系它所托管的ActiveX控件。

A fairly good example of how it works can be found in one of Visual WebGui's forum threads here (controlling a media player ActiveX control), and more information and sample can be found here . 它是如何工作的一个相当不错的例子可以在Visual WebGUI中论坛的一个线程可以找到这里 (控制媒体播放器ActiveX控件),以及更多的信息和样本,可以发现在这里

Palli 帕利

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM