An error occured by ActiveXObject and show Automation server can't create the object

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dondoug
    New Member
    • Sep 2010
    • 1

    #1

    An error occured by ActiveXObject and show Automation server can't create the object

    i have wrote a COM by C#.Net for transfered by a client from web, which i implement by using Javascript...
    i have try all the sovle all i can search from the web,such as :to make the IE security low...
    i also can't solve my problem...now, i need help...it trouble me have 4 days...
    my problem is : when it run on the "var obj = new ActiveXObject(" Wrox.ProCSharp. COMInterop.Serv er.DotnetCompon ent");"//Wrox.ProCSharp. COMInterop.Serv er.DotnetCompon ent is the COM name which i writed.

    there is all my code...thanks for your concerned...
    Code:
    <HTML>
        <HEAD>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <TITLE>Test My DLL </TITLE>
    		
    			
    
            <script language="JavaScript" type="text/javascript">
    		try{
    		var obj = new ActiveXObject("Wrox.ProCSharp.COMInterop.Server.DotnetComponent");
    		}
    		catch(e)
    		{
    			alert(e.message);	
    		}
    		
    		function init()
    		{
    			TestDLL();
    		}
               
    		function TestDLL()
    		  {  
    				try{
    	
    		  		var sum = 0; 
    				sum = obj.add(23, 60);
    				alert("sum is "+sum);  
    				}
    				catch(e)
    				{
    					alert(e.message);
    				}
    		  }
    
    </script>
    
    <OBJECT id = "DotNetComponent" name = "DotNetComponent" classid = "{C54686D5-B2A9-4C98-A744-0F84DC4A0757}" codebase = "DotNetComponent.dll#Wrox.ProCSharp.COMInterop.Server.DotnetComponent"> </OBJECT>	
    <META content="text/html; charset=gb2312" http-equiv=Content-Type>
    
        </HEAD>
        <BODY id=tx_config onload=javascript:init()>
    	
    	
    	<input name="Submit4" type="button" style="width:200px" onClick="javascript:TestDLL();return false;" value="Test DLL Now!!!">
    
           
    </BODY>
    </HTML>
    Code:
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Runtime.InteropServices;
    namespace Wrox.ProCSharp.COMInterop.Server
    {
        [InterfaceType(ComInterfaceType.InterfaceIsDual)]
        public interface IWelcome
        {
            [DispId(60040)]   string Greeting(string name);
        }
    
        [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
        public interface IMath
        {
            int Add(int val1, int val2);
            int Sub(int val1, int val2);
        }
    
        [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
        public interface IMathEvents
        {
            [DispId(46200)] void CalculationCompleted();
        }
    
        [ComVisible(false)]
        public delegate void CalculationCompletedDelegate();
    
        
        [ClassInterface(ClassInterfaceType.None)]
        [ProgId("Wrox.DotnetComponent")]
        [Guid("C54686D5-B2A9-4c98-A744-0F84DC4A0757")]
        [ComSourceInterfaces(typeof(IMathEvents))]
        public class DotnetComponent:IWelcome,IMath
        {
            public DotnetComponent()
            {
    
            }
    
            public string Greeting(string name)
            {
                return "Hello" + name;
            }
    
            public event CalculationCompletedDelegate CalculationCompleted;
            
            public int Add(int val1, int val2)
            {
               int result = val1 + val2;
                if(CalculationCompleted != null)
                    CalculationCompleted();
                return result;
            }
    
            public int Sub(int val1, int val2)
            {
    
                int result =  val1 - val2;
                if(CalculationCompleted != null)
                    CalculationCompleted();
                return result;
            }
    
    
    
        }
    
        
    
    
    
    }
Working...