Reputation: 1321
I am trying to develop a calculation engine and expose the implemented classes as COM objects following this Article. The exposed DLL (Com Object) is going to be consumed by a third-party application. Some older DLLs implemented by VB6 are now using and working properly.
While the final DLL is registered via RegAsm command in the Command Prompt, the COM object becomes visible in the target application but I receive the error messages of
"Failed to create object", "Object has no properties or methods".
What I have tried so far, in addition to the code below, is listed below :
I have created a sample code as an example here, any further help would be appreciated :)
using System;
using System.Runtime.InteropServices;
namespace project_name
{
[Guid("EAA4976A-45C3-4BC5-BC0B-E474F4C3C83F")]
[ComVisible(true)]
public interface ComClass1Interface
{
[DispId(0)]
[ComVisible(true)]
double calc();
}
[Guid("7BD20046-DF8C-44A6-8F6B-687FAA26FA71"),
InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface ComClass1Events
{
}
[Guid("0D53A3E8-E51A-49C7-944E-E72A2064F938"),
ClassInterface(ClassInterfaceType.None),
ComSourceInterfaces(typeof(ComClass1Events))]
public class ComClass1 : ComClass1Interface
{
public double calc()
{
return 13;
}
}
}
The DLL is registered using RegAsm command to be listed on COM Objects.
The Com Object becomes visible to the target application.
When trying to select the implemented method I face these errors :-/:
I am using Visual Studio 2019, C#, .NET Framework 4.0 and the target application is running on Windows Server 2008 R2 and .NET Frameworks 3.5, 4.6 are installed.
Upvotes: 2
Views: 660
Reputation: 1321
The issue solved by These actions:
regasm path/dll-name.dll /codebase /tlb /nologo
Upvotes: 4