0

I am creating a project in visual WebGui, On loading of first page i have taken a ActiveXBox and installed it to the system.

Now I want to access the methods available in the ActiveX control at client side which is already installed in the client machine. 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

Amish Kumar
  • 259
  • 1
  • 3
  • 20

2 Answers2

0

We can achieve this in this way. As the activex control is registered in the com after installing. 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
  • 259
  • 1
  • 3
  • 20
0

@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. 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.

For Visual WebGui Web applications, you have chosen the correct hosting control, ActiveXBox, which will add the ActiveX control to the client's browser. To control it, you usually set "parameters" on the ActiveXBox control, which will then update/contact the ActiveX control it is hosting.

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.

Palli

Palli
  • 191
  • 2
  • hi @user1629973 I am currently running this code on my local system and it is running successfully. So according to you will it not work on server when i will host this? – Amish Kumar Aug 28 '12 at 13:46
  • @AmishKumar True. Your code is a C# code-behind code that will execute on the webserver. In your current implementation running it locally, and as the ActiveX control is installed on your local machine, it so happens that the "terminal" for your desktop and your webserver is the same terminal, it seems to work for you. When deployed to a remote webserver, this is not the case. The server-side code will access a local (meaning server-side) ActiveX control and as for other UI type elements, it will try showing it on its local terminal, which would be the webserver's terminal. Palli – Palli Aug 29 '12 at 09:29
  • @AmishKumar You should consider using the Visual WebGui forums (http://www.visualwebgui.com/Developers/Forums/tabid/364/Default.aspx) to post your questions as they are more likely to be noticed in a timely manner either by the community or the authors. – Palli Aug 29 '12 at 09:34
  • @user1629973 You was right. My code runs only on local machine. when it is hosted on the server it stopped working and throwing com exception error. Now what should i do now? How can i achieve this on client machine? Do you have any idea? – Amish Kumar Sep 18 '12 at 10:32
  • @AmishKumar See this CodeProject article [here](http://www.codeproject.com/Articles/14533/A-Complete-ActiveX-Web-Control-Tutorial). I believe it will show you most of what you need to know, but of course you need to customize the Visual WebGui control (add the necessary scripts) to be able to use it in your Visual WebGui application. Seems to be fairly trivial though. Use "Script For" for registering to events and the ActiveX methods seems to be called directly. – Palli Sep 30 '12 at 01:59