I want to use x86 dll in in my x64 C# application! On forum I read that com object will help me! This is my ComServerSample. It is compile like x86.
[ComVisible(true)]
public class MyComServer : IMyComSample
{
private dahuaIp.fDisConnect dissconn;
public void con(int lLoginID, StringBuilder pchDVRIP, int nDVRPort, int dwUser)
{
}
public string GetString()
{
dissconn = new dahuaIp.fDisConnect(con);
var zdsc = dahuaIp.CLIENT_Init(dissconn, 0);
return zdsc.ToString();
}
}
[ComVisible(true), Guid("DBE0E8C4-2222-41f3-B6A4-4E2F353D3D05")]
public interface IMyComSample
{
string GetString();
}
And this is test application for using this com server
Type CSI = Type.GetTypeFromProgID("ComServerSample.MyComServer");
var COMobj = Activator.CreateInstance(CSI);
MethodInfo method = CSI.GetMethod("GetString", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
var sdfc = method.Invoke(COMobj, null);
When test app is x86!This two applications work fine! But when test app is x64 there is an eroor :
Failed to get the COM class factory for component with CLSID {7B9F9A71-8E1B-3470-8A79-EEB4DA9B25A4} due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
How solve problem? I need to use my x86 dll in x64 application!