Click here to Skip to main content
15,886,063 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
XML
CLASS FILE
--------------------
using System;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;

namespace External
{
    public class Class1
    {
        public string Test()
        {
            return "Hi.. from External DLL.";
        }
    }

}


-----------------------------
HTML CODE

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title>New Document </title>
    <script type='text/javascript' language='javascript'>
        function comEventOccured() {

            try {

                alert("After ActiveX");
                var myobject = new ActiveXObject("External.Test");
                alert("Before ActiveX");
                alert("Test1");
                alert(myobject.TestMethod()); // call TO DLL Function.
                alert("After Call");
            }
            catch (e) {
                alert(e.message);
            }
        }
        function startWord() {
            var strFile = "D:\\Temp\\File\\Doc.doc";
            var myApp = new ActiveXObject("Word.Application");
            if (myApp != null) {
                myApp.Visible = true;
                myApp.Documents.Open(strFile);
            }
        }
        function RunExe() {
            w = new ActiveXObject("WScript.Shell");
            w.run('notepad.exe');
            return true;

        }
    </script>
</head>
<body>
    <input type="button" value="Call Method from DLL" onclick="comEventOccured()">
    <br />
    <input type="submit" value="Start Word Doc" onclick="startWord()">
    <br />
    <input type="submit" value="Start Notepad" onclick="RunExe()">
</body>
</html>




------------------------------

This working fine for startWord() and RunExe() but for comEventOccured()
its giving msg of "Automation server can't create object"


Thanks in Advance.
Posted
Updated 23-Feb-15 0:39am
v2

1 solution

Then External.Test simply isn't installed. Check component services or simply try to (re)install the component.

Good luck!
 
Share this answer
 
Comments
Nitin_Bharekar 24-Feb-15 0:32am    
Thanks..

External.Test is already Installed..
Even after reinstalling is its Not working.
E.F. Nijboer 24-Feb-15 12:25pm    
Are you sure? You can check it using oleview.exe
Check this link for more info:
https://msdn.microsoft.com/library/d0kh9f4c.aspx
Nitin_Bharekar 25-Feb-15 1:47am    
I thought you are talking about registering DLL using RegAsm.exe tool.
I will check the link.
Thanks.
Nitin_Bharekar 25-Feb-15 7:43am    
Hi Nijbober.

I gone through the link. but I don't know how to use oleview.exe.

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