Hi,
I am new to COM and is trying to build a simple c dll that calls managed code but when I create the CDLL and run it I get the error "Unable to find assembly". We have an MiddleTier project written in managed code(mainly C#)with multiple projects, however we must create a dll using unmanaged code(using c) that talks to this layer.Originally this code is launchedvia an exe. To simplify things I created a managed library(bridge code)that talks to this MiddleTier Layer. Use regasm to create tlb file and set the assembly as COM visible. I have also created a c dll that calls the managed code. To test this I created a console application that loads the dll but when I debug into it I get unable to find assembly for the managed code. Do I also need to make the managed code COM visible or is there another step that needs to be done? Is there an alternate way that I can accomplish this? Any advice is appreciated.
Thanks,
//This is the call in the CDLL
__declspec
(dllexport)
(dllexport)
double GetStartFrequency()
{
HRESULT hr = CoInitialize(NULL);
IManagedClassPtr pICalc(
__uuidof(ManagedClass));
double result = 0.0;
pICalc->GetStartFrequency(&result);
CoUninitialize();
return result;
}
//This is bridge class that talks the MiddleTier layer. A reference is added to this project
public
class ManagedClass : IManagedClass
{
MT.ISystem systemControl =
null;
public ManagedClass()
{
this.Initialize();
}
public void Initialize()
{
IObjectFactory objectFactory = RootFactory.Instance.GetFactory("");
try
{
systemControl = objectFactory.GetSystemControl(
"");
objectFactory.DeserializeSetup();
systemControl.StartSystem();
}
catch (Exception ex)
{
throw ex;
}
}
public int Add(int Number1, int Number2) //for testing
{
return Number1 + Number2;
}
public double GetStartFrequency()
{
return systemControl.StartFreq;
}