Solved

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

Posted on 2007-11-28
7
754 Views
Last Modified: 2013-11-26
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

0
Comment
Question by:Pall Palsson
  • 3
  • 2
7 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 20370480
you don't have the choice to use regasm.
0
 

Author Comment

by:Pall Palsson
ID: 20372707
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 ?
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 20373052
0
The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

 

Author Comment

by:Pall Palsson
ID: 20378594
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.
0
 

Author Comment

by:Pall Palsson
ID: 20440572
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

0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 20615325
PAQed with points refunded (250)

Computer101
EE Admin
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question