Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
first of all, i opened a class library project and add the following code!
C#
using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Drawing.Printing;
using System.Windows.Forms;
using System.Text;


namespace unamespace
{
    interface iclass
    {
        string fname();
        string sname();
        void box();
    }

    [ClassInterface(ClassInterfaceType.AutoDual)]
   
    public class uclass : iclass
    {
        public string fname()
        {
            return "umair";
        
        }
        public string sname()
        {

            return "ali";
        
        }
        public void box()
        {
            MessageBox.Show("testing winform tools");
        
        }

    }
}


2-then following some tutorial, i compiled the my .cs file using csc.exe compiler
3-then i registered unamespae.dll using regasm.
all done correctly.
4- i wrote a test html page to check my activex control.
JavaScript
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>umairXXX</title>
    <script type="text/javascript">
        var x = new ActiveXObject(unamespace.uclass);
        alert(x.fname());
        alert(x.sname());
        alert(x.box());
    
    
    </script>
</head>
<body>

</body>
</html>


but when i opened that html page in ie, nothing happens. only a warning occurs that seeks permision to allow activex controls to run in ie. nd nthing happens :-(
Posted
Comments
hina_abbas123 26-Oct-13 17:09pm    
:-(
no answer yet!
Sergey Alexandrovich Kryukov 27-Oct-13 0:48am    
Why creating ActiveX controls at all? How is it related to JavaScript? Isn't it about using ActiveX in IE?
—SA
hina_abbas123 27-Oct-13 1:12am    
script that have been written is in java script. thats why it is related to javascript.
actually i want to create activex control for a printer. and it was just the beginning. COM object that will be created, ll have to be embedded in already running app.
Sergey Alexandrovich Kryukov 27-Oct-13 1:48am    
ActiveX in browser is evil. Many users will put your site in a not-visit list if they find out that you use ActiveX, it would mean that you don't consider basic security issues. And it's only for IE and Microsoft systems.
—SA
hina_abbas123 27-Oct-13 2:33am    
yes i know, actually the software i am working for ll not put on www. it ll run on local network. and ofcourse on IE

1 solution

XML
ActiveX can also run on Chrome with a simple plugin. You find that PlugIn in Store. try it. Search for "ActiveX for Chrome" on google.
For your problem, see <a href="http://forums.asp.net/p/1947676/5551928.aspx?Loading+ActiveX+with+object+tag">Loading ActiveX with object tag</a>, Syntax for loading dll cab is not correct in javascript. You should use &lt;OBJECT id="myCab" classid="clsid:YOUR_CAB_GUID">&lt;/OBJECT>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900