Link to home
Start Free TrialLog in
Avatar of Pall Palsson
Pall PalssonFlag for Iceland

asked on

How to create a DLL using Visual Studio C# that registers with regsvr32 NOT regasm ?

Hi,
I'm trying to create a DLL to use in an application that is not .net.  (Actually Microsoft Dynamics Nav not that it should matter)

Anyways I created a class library and compiled to dll.  However I can only register it using regasm /tlb option.  This in return always gives me the Entry Point not found in the other application.  So my feeling is that I need to build some interface or something on top ?
public class TestDLL
    {
        private string myString = "EMPTY";
 
        public Tenging()
        {
        }
 
        public string MyProperty
        {
            get
            {
                return myString;
            }
            set
            {
                myString = MyProperty;
            }
        }
    }

Open in new window

Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

you don't have the choice to use regasm.
Avatar of Pall Palsson

ASKER

First off the code snipped is wrong in the way that the constructor should of course be of TestDLL().

Anyways I don't understand what you mean by that !  Right now my only choice seems to be regasm but the result is not what I expect as when I try and use the DLL I always get the DLL Entry Point not found error.

Upon further reading I'm starting to think that I need to write some sort of COM wrapper or Interop.

Does anyone have a link to a good sample ?
Perhaps I'm not explaining the problem correctly.

What I want to accomplish is making a "old school" COM DLL using c#.net.  I can make a DLL that publishes its interface to .Net but not Win32.

I tried making a simple Class library using the ComClass in VB.net but that gave me the same result.  The Inteface (methods, attributes etc) is not published so when I open the DLL in a program like DLL Export Viewer it comes up empty.
Got it to work

Application->Assembly Information->Check Make Assembly COM-Visible
Build->Settings->Check Register for COM Interop
Signing->Check Sign the Assembly
using System.Runtime.InteropServices;
 
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface ITestDLL
{
    [DispId(1)]
    string MyProperty {get; set; }
}
 
[ClassInterface(ClassInterfaceType.None)]
[ProgId("<Namespace>.TestDLL")]
public class TestDLL : ITestDLL
{
    etc.

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial