Install .NET COM + dll

I have the following COM object installed on one of our servers that I need to rewrite ... some old code uses the object as follows:

Set oEmail = CreateObject("SSDSCommunicator.EmailClass") oEmail.Send(szFrom, szRecipients, szSubject, szEmailBody, SMTPServer, szErr, "", , , , True) 

I followed suit in this , but I'm struggling to register a COM component.

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web.Mail; using System.Runtime.InteropServices; namespace SSDSCommunicator { [InterfaceType(ComInterfaceType.InterfaceIsDual), Guid("DB38A91C-9EB6-4472-9A49-40722431E096")] public interface IEmailClass { void launch(); bool Send(string szFrom, string szTo, string szSubject, string szMessage, string szSMTPServer, ref object szError, string szAttachments = "", string szReplyTo = "", string szCC = "", string szBCC = "", bool bHTMLBody = false); } [ClassInterface(ClassInterfaceType.None), Guid("A00C16DA-1791-4A3A-8D16-4765A9FAD060"), ProgId("SSDSCommunicator.EmailClass")] public class EmailClass : IEmailClass { private string path = null; public void launch() { Console.WriteLine("I launch scripts for a living."); } public bool Send(string szFrom, string szTo, string szSubject, string szMessage, string szSMTPServer, ref object szError, string szAttachments = "", string szReplyTo = "", string szCC = "", string szBCC = "", bool bHTMLBody = false) { ... } } } 

The project is successfully completed. How to register a dll as a COM object so that the old VB6 code works?

I marked the register for COM interoperability and will make COM assemblies visible in the project settings.

I was not lucky with regsvr32 (no entry point) or regasm ...

The COM object looks like this on the old server:

enter image description here

Edit

Should I see a COM object in component services after running the regasm command?

 regasm C:\...\SSDSCommunicator.dll /CodeBase 
+4
source share
2 answers

OK sweet ... found the answer to this thanks to user957902 and GTG (write a few answers below if you want points):

  • Targeted x86 solution
  • Signed assembly using .snk file
  • Inherited ServicedComponent
  • Manually added the SSDSCommunicator component to the component services, and then added the dll as a component

The final code is below:

  using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web.Mail; using System.Runtime.InteropServices; using System.EnterpriseServices; namespace SSDSCommunicator { [InterfaceType(ComInterfaceType.InterfaceIsDual), Guid("DB38A91C-9EB6-4472-9A49-40722431E096")] public interface IEmailClass { bool Send(string szFrom, string szTo, string szSubject, string szMessage, string szSMTPServer, ref object szError, string szAttachments = "", string szReplyTo = "", string szCC = "", string szBCC = "", bool bHTMLBody = false); } [ClassInterface(ClassInterfaceType.None), Guid("A00C16DA-1791-4A3A-8D16-4765A9FAD060"), ProgId("SSDSCommunicator.EmailClass")] public class EmailClass : ServicedComponent, IEmailClass { private string path = null; public bool Send(string szFrom, string szTo, string szSubject, string szMessage, string szSMTPServer, ref object szError, string szAttachments = "", string szReplyTo = "", string szCC = "", string szBCC = "", bool bHTMLBody = false) {... } } } 
0
source

On a 64-bit system, there are two COM domains. One for 32-bit COM objects and other 64-bit COM objects. If your .Net assemblies are ANY_CPU, then by default it will start working as a 64-bit process on a 64-bit system. If your COM object is reloaded as 32 bits only, then the 64-bit process will not be able to see it. The converse also matters if the COM object is overloaded only as 64-bit, then the 32-bit process cannot see it.

+1
source

Source: https://habr.com/ru/post/1381292/


All Articles