Title: How to invoke an ActiveX Control using javascript in an ASP.NET page
Tags: asp.net;com;activex
Question: I'm trying to create an Active X component that will start an application on a client machine. I've created an Active X control which is quite straight forward in .NET. ALl it does is call the Process class and call Start. 

Now i want to be able to call the starting method on this class from javascript passing in a few parameters on the page (which are then passed down as command line arguments).

I followed the guide here: http://www.c-sharpcorner.com/UploadFile/mgold/HyperlinkExec03012007191054PM/HyperlinkExec.aspx

This guide talks about using a hyperlink to start the javascript but i'm using a button. Here is my HTML (i'm trying this in just plain HTML instead of ASP.NET to keep things simple for now but i want to go to ASP.NET eventually)

```<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml" &gt;

    <body&gt;
        <button type="button" onclick="javascript:launch()"&gt;Click me!</button&gt;
        <script type="text/javascript"&gt;
            function launch()
            {
                alert('test')
                var myLauncher = new ActiveXObject('CardWriterApplicationLauncher');
                myLauncher.LaunchCardWriter('test', 'test', 'test');
            }
        </script&gt;

    </body&gt;
</html&gt;
```

How when i click the button i get the error "Automation server can't create object". I know that my COM dll is registered properly in the GAC and with regasm, so what could i be doing wrong?

Also any alternative solutions to launching the application on the users desktop from a web page would be greatly appreciated. Browser security setting can be modified as required as the client PCs are under our control and are on a private network with no internet access.

Thanks



Here is another answer: If you have public properties or methods in the ActiveX control can you not just call those directly referencing the ```<Object&gt;```'s ID using JavaScript?

So the ActiveX control is already loaded on the page using the ```<object&gt;``` tag, and you're just calling its method.

Comment for this answer: How would i go about using the object tag. I've seen some information about it, but never managed to get it to work.
Comment for this answer: Search for how to embed an activeX control in an hmtl page see: http://www.fpoint.com/support/whitep/ActiveX/ax1999.aspx This will display control on the page (in your case, it might not have an interface, but you can add one to test it) Once you have the control on the page you can then start interacting with it using javascript.

Here is another answer: Throw away the browser for a moment and go to the client machine, make sure you can create the activex object correctly on the machine, use a simple vb script or dummy app.  

Create a file called something.vbs, in it put the following code

```Set MyObj = CreateObject("CardWriterApplicationLauncher")
```

Once you have verified that part is working go to your browser. 

Its likely your issue has nothing to do with your browser.

Also I just noticed CardWriterApplicationLauncher isn't a valid Object Identifier they ususally require a . in them.  eg ```word.application```


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 2.5', 'CreationDate': '2009:00:09/03/09', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<asp.net><com><activex>', 'Title': 'How to invoke an ActiveX Control using javascript in an ASP.NET page', 'ViewCount': 7770, 'id': 1373968, 'user_AboutMe': '<p>A contract .NET developer operating in the North West of England, UK</p>\n', 'user_AccountId': 14973.0, 'user_DisplayName': 'Dafydd Giddins', 'user_Reputation': 2226.0, 'user_Views': 192.0, 'user_id': 1458933.0}}