Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi all
i have created activex page in asp.net
and calling it from web page through javascript

this my code for calling it:
XML
<head> <title>C# ActiveX Test</title> </head>


<body onload="myload();">
<h1>This is Our ActiveX Test Page</ h1>

The message from the ActiveX Control is
<div id="axmsg"></div>


<script type ="text/javascript">
    function myload() {
        var myAx = new ActiveXObject("ClassLibraryFinger");
        if(myAx != null) {
            myAx.ShowDialog("hello from asp.net");
            var d = document.getElementById("axmsg");

            var s = myAx.Hello();
            d.outerText = s;
        }
        else
            alert("NOOOO... we failed");
    }
</script>
</body>


when i m running this project i m getting error as:
Microsoft JScript runtime error: Automation server can't create object


i have registered my active x dll with regasm
i have added it to web application
but it is not working
thank you
god bless u all :)
Posted

Hi,

This error happen because your code is try to perform some risky task, so browser blocking you.

So you can try this

Open IE > Tools > Internet Options > Security > Custom Level > (Enable Active X )
 
Share this answer
 
Comments
MAU787 16-Jul-12 5:03am    
Thank u for ur reply..
i have made it enable but still it is giving same error...
Suvabrata Roy 16-Jul-12 5:09am    
Please write the error details...
MAU787 16-Jul-12 5:20am    
hi.
it is giving me only following error and it stops running..
Microsoft JScript runtime error: Automation server can't create object
i tried to google it
i have changed the settings in IE in options for activex enable
but it is not working


details:
i have taken class library and written some code for displaying error
then i have build it and also registered it in studio cmd
then added to website by add reference
and the written a java-script to access its function
Suvabrata Roy 16-Jul-12 5:26am    
I think your problem is different you are try to access some Custom DLL using Active X and result of which your code may run at you machine but it will surely not run on other machine where that DLL is not registered.

This is not a good way to access Active X dll if you explain you requirement is details then I can try to solve your problem...
I had tried this..

Open IE >> Tools >> Internet Options >> Security >> Custom Level >>(Enable) Initialize and script ActiveX controls not marked as safe for scripting


You Javascript for ActiveX will surely run.


Thanks
Ashish

Mark it solution if this is your answer..
 
Share this answer
 
Comments
MAU787 16-Jul-12 5:03am    
Thank u for ur reply..
i have made it enable but still it is giving same error...
hi..
i solved it
After registering dll it was not present on the following path
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE
so i copy-paste it
and

XML
<script type ="text/javascript">
    function myload() {
        var myAx = new ActiveXObject("ClassLibraryFinger.Class1");
        if(myAx != null) {
            myAx.ShowDialog("hello from asp.net");
            var d = document.getElementById("axmsg");

            var s = myAx.Hello();
            d.outerText = s;
        }
        else
            alert("NOOOO... we failed");
    }
</script>



added my class name after the dll name in activex object
Thank you...:)
 
Share this answer
 
Comments
Suvabrata Roy 16-Jul-12 5:32am    
This solution will work only in your system not in other system.

Because your code may run at you machine but it will surely not run on other machine where that DLL is not registered.

:)
MAU787 16-Jul-12 5:38am    
yep
i got that point just now..:)
now thinking of another new problem..how to solve..;)
Suvabrata Roy 16-Jul-12 7:05am    
Please tell me what you want to do ?
MAU787 16-Jul-12 7:55am    
actually i wanted to check whether we can call activex methods from javascript becoz i wanted some functions to be happen on server only
but it is running on my pc not on others.. u said so it will not work.
so now trying to find another way of doing it.
Suvabrata Roy 16-Jul-12 8:18am    
I think you need some Secure java script?

If So then I can help you...

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