[Last Call] Learn how to a build a cloud-first strategyRegister Now


Creating DLLs in .NET (C#) for to use in legacy environments

Posted on 2007-07-19
Medium Priority
Last Modified: 2010-04-14
How do I create a DLL in .NET 2005 C# such that it can be referenced in legacy environments like VB6 and Delphi 7.  When I try to import normally compiled class libraries created in .net they cause in error in older environments.
Question by:fbk2000
LVL 52

Accepted Solution

Carl Tawn earned 1000 total points
ID: 19526400
You need to go into the project properties and set the "Register for COM interop" flag on the "Build" tab. When you build the assembly it will be given a COM callable wrapper which will then allow you to use it like any other COM library.

Assisted Solution

illusio earned 1000 total points
ID: 19530019
Checking the "Register for COM interop" is a beginning but not the entire solution
Everytime I must do it I have to search the internet myself for the exact things to set.
The problem is not making something COMVisible - the main problem lies in that you need to attribute all the necessary GUID's for ClassID's on Interfaces, Classes  and eventhandlers.

A quick search revealed this article that has a nice working example (don't forget to read the update lower on the page where the author corrects a mistake he made in his code and definitely ignore the part on which he hails VB.NET for the better handling of COM ;-) )

In general if you want to make a COM Visible class:
Create the interface with all the properties, methods and events you want to expose
Apply the correct attributes to attribute the different GUID's.
Implement your interface and build as usual. Sign the assembly and make it installable in the GAC and  after installing in the GAC you have a fully working COM object. The GAC thing is not really necessary but most of the time if you make a COM object you want to make it available over the entire computer and not private to a project.

Kind regards,

Kind regards,

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

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…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses
Course of the Month18 days, 10 hours left to enroll

834 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