How to convert a COM assembly to a CLR assembly?

How to convert a COM server to a CLR assembly so that I don’t have to rewrite anything first.

+3
source share
1 answer

I posted this here for the OP, as they sent it by default as a question edit.

Instead of rewriting the COM server (written in 1992 using C ++ / MFC) to .Net, I decided to convert it to a CLR assembly. To take a COM assembly (add32.exe) and use it with a .Net client, we need to create a called shell. Run all the tools using the Visual Studio command prompt (as an administrator).

Step 1: Sign a COM Node with a Strong Name

enter image description here

Step 2: Convert the definitions found in the COM library to the CLR assembly

, COM, CLR Tlbimp.exe. Tlbimp.exe - (), , . - DLL . , .Net COM-.

enter image description here

3. ILDASM.EXE .

enter image description here

CLR, . dll .

enter image description here

, COM-, , , 2.

#using "Add32Pkg";

, COM:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using Add32Pkg;

namespace TestAdd32
{

    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {

            Add32Server Add32 = new Add32Server();
            Add32.Init(201);
        }
    }
}
0

All Articles