hello everyone.
i have created a com+ made by C#.
The COM+ is singleton.
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[Guid("9b7384f1-7fd3-444f-acd9-0551ae878caf")]
public interface IOpenInterface
{
bool K_SetEventId(string strSourceId, string strEventId);
int test();
}
[JustInTimeActivation]
[ObjectPooling(Enabled = true, MinPoolSize = 1, MaxPoolSize = 1,
CreationTimeout = 5000)]
[Guid("6d1bcaf4-1d35-44c5-b7cb-7431550ee9c0")]
[ProgId("EasyEda.OpenInterface")]
[ComVisible(true)]
public sealed class IOpenComponent : ServicedComponent, IOpenInterface
{
public IOpenComponent() { }
public int test()
{
System.Diagnostics.Debugger.Break();
return 10;
}
public bool K_SetEventId(string strSourceId, string strEventId)
{
System.Diagnostics.Debugger.Break();
return CEdaInterface.edaInstance.K_SetEventId(strSourceId,
strEventId);
}
}
i called the test function from dll made by c++.
it's ok.
but i called the other function from dll made by c++.
but a error was happened.
CoInitialize(NULL);
HRESULT hr = CoCreateInstance(CLSID_IOpenComponent ,
NULL, CLSCTX_LOCAL_SERVER,
IID_IOpenInterface ,
reinterpret_cast<void**>(&gIOpenInterface));
if(FAILED(hr))
{
OutputDebugString("The Interface failed");
return FALSE;
}
printf("%d\n", gIOpenInterface->test());==> it's ok.
_bstr_t bstr = ::SysAllocString(L"TEST");
gIOpenInterface->K_SetEventId(bstr, bstr);==> The error was happened.
i tried to solve this problem many times..but i can't...
anyone help me solve this problem.
best regards.
Willy Denoyette [MVP] - 29 Jan 2008 11:10 GMT
> hello everyone.
>
[quoted text clipped - 54 lines]
> _bstr_t bstr = ::SysAllocString(L"TEST");
> gIOpenInterface->K_SetEventId(bstr, bstr);==> The error was happened.
This should work, please post the error message.
Willy.
Note: this issue relates to C++, you might get better answers when posting
to the microsoft.public.vc.language group or to the interop
microsoft.public.dotnet.framework.interop NG.
lightdoll - 30 Jan 2008 04:06 GMT
Thank you for your reply.
return CEdaInterface.edaInstance.K_SetEventId(strSourceId,
strEventId);
==> i think a part of this has some problem.
because i don't anything in test(), but i called another dll from K_SetEventId
but i don't modify the code yet.
public int test()
{
System.Diagnostics.Debugger.Break();
return 10;
}
public bool K_SetEventId(string strSourceId, string strEventId)
{
System.Diagnostics.Debugger.Break();
return CEdaInterface.edaInstance.K_SetEventId(strSourceId,
strEventId);
}
> hello everyone.
>
[quoted text clipped - 60 lines]
>
> best regards.
Willy Denoyette [MVP] - 30 Jan 2008 09:36 GMT
> Thank you for your reply.
>
> return CEdaInterface.edaInstance.K_SetEventId(strSourceId,
> strEventId);
> ==> i think a part of this has some problem.
But what's the problem, any error message?
You are connected to a singleton, why are you calling back into
K_SetEventId? What are you trying to achive here?
Willy.