Sorry, I'm very new to COM, and I'm trying to figure stuff out. So I created some test COM-object in C# based DLL:
using System.Runtime.InteropServices;
using System.Diagnostics;
using System;
[ComVisible(true)]
[Guid("<interface_guid>")]
public interface IMyTest {
string Test();
}
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[Guid("<class_guid>")]
public class MyTest : IMyTest {
public string Test() {
var pro = Process.GetCurrentProcess();
var mac = Environment.MachineName;
return $"{mac} - {pro.Id} - {pro.ProcessName}";
}
}
And I'm registering this COM C# based DLL using this code:
var asm = Assembly.LoadFrom("<path_to_the_dll>");
var reg = new RegistrationServices();
reg.RegisterAssembly(asm, AssemblyRegistrationFlags.SetCodeBase);
Now I can use this object from VBScript like that:
set obj = CreateObject("MyTest")
WScript.Echo(obj.Test)
This works fine, however I need to be able to access this COM object from other computers on the LAN. When I try doing it even on the same computer I get an error:
' Unable to create ActiveXObject
set obj = CreateObject("MyTest", "localhost")
WScript.Echo(obj.Test)
So the question is how do I register my COM DLL in the way that it will be accessable for calling from the other computers on the LAN? Can I make the COM DLL to always be hosted in the dllhost.exe process (COM Surrogate) instead of being loaded into the caller process?