locked
Error:- Dllregisterserver entry point was not found 'regsvr32 /i <Dll>'

    Question

  •  

    hi all,

    I have an .net Dll and I have to interact it with 'ASP'.

    How can I achive this..?

    when I am registering the Dll  by using "regsvr32 /i <Dll Path> "  Then  I am getting this Error: Dllregisterserver entry point was not found.

    I am enable the  'Register for COM interop' in the Build option in the Propertis of the Application.



    Wednesday, August 27, 2008 12:54 PM

All replies

  • .NET assemblies are not registered using regsvr32.  Instead you need to use regasm. 

    Michael Taylor - 8/27/08
    http://p3net.mvps.org
    Wednesday, August 27, 2008 1:07 PM
  • thanks for reply,

    But What will the solution ..?

    in which web link I will get more information on this ?

    I have the following code
    -------------------------------------------------------------------------------------

    using System;
    namespace clsLibSample
    {
        public class clsLibSample
        {
            public static string fnStrReturn()
            {
                return "This is my second DLL Application";
            }

            public void fnValue()
            {
                int intA, intB;
                intA = 100;
                intB = 200;
                string str = Convert.ToString(intA * intB);
          
            }
        }
    }

    Wednesday, August 27, 2008 1:25 PM
  • murthysrn said:

    thanks for reply,

    But What will the solution ..?

    in which web link I will get more information on this ?

    I have the following code
    -------------------------------------------------------------------------------------

    using System;
    namespace clsLibSample
    {
        public class clsLibSample
        {
            public static string fnStrReturn()
            {
                return "This is my second DLL Application";
            }

            public void fnValue()
            {
                int intA, intB;
                intA = 100;
                intB = 200;
                string str = Convert.ToString(intA * intB);
          
            }
        }
    }



    Wednesday, August 27, 2008 1:25 PM
  • Your code is not COM-related so registration will do nothing as given.  The full details of how to make a COM class in .NET is too much for a post.  The general steps are:

    1. Create a .NET interface to expose to COM.  Only COM-visible and PODs (plain old data types) can be used.
    2. Add the ComVisible, Guid and InterfaceType attributes to the interface.
    3. Create a .NET class to expose to COM.
    4. Add the ComVisible, Guid and ClassInterface attributes to the class.
    5. Optionally add the ProgId attribute to your class to give your class a nice COM name.
    6. If necessary add the Guid attribute to the assembly.
    7. Compile your code.
    8. Run regasm to register your interface and coclass with COM. 

    The key is to not rely on the compiler to autogenerate COM interfaces or GUIDs for you.  Be explicit.  If you don't then things can become very complex as your COM development continues.

    Here are some links:

    http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.aspx
    http://www.codeproject.com/KB/COM/nettocom.aspx
    http://blogs.msdn.com/heaths/archive/2005/03/09/391358.aspx
    http://msdn.microsoft.com/en-us/library/sd10k43k.aspx

    Michael Taylor - 8/27/08

    • Proposed as answer by jack 321 Friday, August 29, 2008 7:59 AM
    • Marked as answer by jack 321 Monday, September 01, 2008 2:32 AM
    • Unmarked as answer by murthysrn Thursday, September 04, 2008 8:33 AM
    Wednesday, August 27, 2008 2:36 PM
  • The above post is essentially correct.  There's allot you need to do to create a valid COM object accessible via programs like ASP and VB6.  Here's some more information that should prove to be helpful.

    The problem with registering a .Net object for COM interop is COM doesn't know where to find your DLL even after you register it. You must add the CodeBase registry entry which points to your DLL's location. The easiest way to do that is with an installer. Build an installer, extract the registry information, then add the CodeBase. Most installers will allow you to use a variable for this purpose so if the user installs the DLL to a different folder, the CodeBase will always point to the correct location. For example, in InstallAware, on the Registry tab, you can click the Import button which allows you to browse to your DLL. Once you select it, it will automatically import the registry settings for you. However, you must still add the CodeBase with code similar to this: Key = CodeBase Value = $TARGETDIR$

    Here's something else to keep in mind. When creating a DLL for COM interop, there can only be one public class with a single, non-parameterized entry point. Be sure to mark any other classes or functionality you don't wish to expose as Internal (C#) or Friend (VB).

    You also might want to specify the COM interface.  (Steps 1 and 2 in above post.)  That allows you to assign dispatch ID's to each property and method. This is important in case you ever change things. COM doesn't guarantee the order in which things are registered but if you specify an interface, you can control it so if you add new functionality, you don't break existing objects that use your DLL (i.e. DLL ____).  Here's an example of a COM interface in C#:

    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsDual)]
    public interface IMyComDll
    {
        // Properties
        [DispID(1000)]
        string UserName { set; get; }

       [DispID(1001)]
       string Password { set; }
       
       // Methods
       [DispID(2000)]
       bool Login()
    }

    And here is an example of a COM class with attributes applied in C#:

    [ProgID(MyCompany.MyComDll)]
    [GuidAttribute("2ACCAC23-BB7A-4b90-8535-9ABC62AABB10")]
    [ClassInterface(ClassInterfaceType.AutoDispatch)]
    public class MyComDll : IMyComDll
    {
       public MyComDLL()
       {
       }
       
       // Implement Interface Here

       }

    I realize that it'll take some research into creating an installer and/or creating a COM interface but I leave that as an exercise for you. I just wanted to point out the fact there is more to writing a COM object in .Net than appears at first.
    Thursday, May 28, 2009 11:14 PM