Solved

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

Posted on 2007-11-28
7
734 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 69

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 69

Expert Comment

by:Éric Moreau
ID: 20373052
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now