消息“自动化服务器无法创建对象” [英] Message of "Automation server can't create object"

查看:69
本文介绍了消息“自动化服务器无法创建对象”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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.

推荐答案

然后就没有安装External.Test了。检查组件服务或只是尝试(重新)安装组件。



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

Good luck!


这篇关于消息“自动化服务器无法创建对象”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆