Skip to content

C# DLL

richard lim

Asked Jun 3, 2007, 7:26 PM EDT6 answers
Share
LinkedInX

Is it possible, I have a dll i create it in c#, can i call this dll in vbscript or asp and if possible how? 

6 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    yes, it is

    reference...

    using System.Runtime.InteropServices;
    //after the namepace name
    [ComVisible(true), ProgId("YourClass.Application")]

    just do a....in vbscript or asp

    set objMydll = CreateObject("YourClass.Application")

    0
  • 0

    My c# dll name is clsFunc.dll
    No display in my page what seems to be the error?
    <SCRIPT LANGUAGE="vbscript" runat="server">
     
     Dim obj,strSend

     Set obj = Server.CreateObject("clsFunc.Class1")
     
     strSend = "Add - " & obj.PerformAddition(15, 9) & vbCrLf & "Minus - " & obj.PerformSubtraction(114, 10)

     Msgbox strSend
      
    </SCRIPT>


    0
  • Mike Gold
    0
    You need a COM callable wrapper (CCW) in your C# dll.  Then it becomes accessible from javascript or vbscript.   See my article on the topic.

    Best,
    0
  • 0

    Server object error 'ASP 0177 : 800401f3'

    Server.CreateObject Failed

    /xotrack_testsite/polo4050/mytest/testme.asp, line 11

    800401f3

    Above is the error in my internet explorer below is my c# dll code kindly check pls. tnx.

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.EnterpriseServices;
    using System.Runtime.InteropServices;

    [assembly: ApplicationAccessControl(true)]

    namespace clsFunc
    {
        [Guid("5C63A021-EDEF-4044-B9DE-93036C5FCDD9")]
        [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]

        public interface iInterface
        {
            [DispId(1)]
            int PerformAddition(int a, int b);       
            int PerformSubtraction(int a, int b);       
        }      
        [ProgId("clsFunc.Class1")]
        [ClassInterface(ClassInterfaceType.None)]
        public class Class1 : ServicedComponent, iInterface
        {  
            public int PerformAddition(int a, int b)
            {       
                try
                {
                    return a + b;
                }
                catch
                {
                    return 0;
                }
            }

            public int PerformSubtraction(int a, int b)
            {        
                try
                {
                    return a - b;
                }
                catch
                {
                    return 0;
                }      
            }

        }
    }

    0
  • Mike Gold
    0
    If the server can't create the object then it is not registered with COM.  You must strong name the server object, put it in the gac, and register it with COM using regasm.  Please look at my article on the topic, I'm pretty sure it will help you.
    0
  • 0
    Hi Mike, 

    I already read your article it helps, i already registered my dll in my computer maybe the problem is in the server maybe what i need to do is to remotely registered it in the server any idea.

    Thank you very much.
    0