(1) The COM object uses CoCreateInstance to initalized C# comsible .Net class
(2) Teh COM object uses C++ Mixed Managed and unmanaged code feature.
Here are the code snippets:
// C# COM object
#import "C:\Working\JQDXIPCOMCS\Debug\JQDXIPCOMCS.tlb"
STDMETHODIMP CXIPVCAddin::AppStartUp( VARIANT_BOOL* pnComponentInitialized)
{
HRESULT hr = CoInitialize(NULL);
JQDXIPCOMCS::IXIPEventHandlerPtr pEH(__uuidof(JQDXIPCOMCS::XIPEventHandler));
// ATL C++ COM with /clr at project or file level
#import "C:\Working\JQDTestCOM\JQDTestCOM\Debug\JQDTestCOM.tlb"
STDMETHODIMP CXIPVCAddin::AppStartUp( VARIANT_BOOL* pnComponentInitialized)
{
HRESULT hr = CoInitialize(NULL);
JQDTestCOMLib::IClass1Ptr p(__uuidof(JQDTestCOMLib::Class1));
// alternative ATL COM objet initiation
CComPtr
::CoCreateInstance(__uuidof(JQDXIPCOMCS::XIPEventHandler),NULL,CLSCTX_ALL,
__uuidof(JQDXIPCOMCS::IXIPEventHandler), (void**) &pH);
The following are the workaround until this problem can be solved:
HINSTANCE h=ShellExecute(NULL,"open","C:\\XIP_GMO\\OrdAlloc.exe","c:\\MyLog.log","",SW_SHOW);
It turn out that xip.exe.config did not specify CLR runtime version and codebase for registered COM may not point to the right place. We just need to do the folowing:
1) Add <supportedRuntime version="v2.0.50727" /> in xip.exe.config
2) Create a new directory GMOCSharpCOM on app server and set CodeBase of all C# COM object to this directory. e.g. CodeBase file:///X:/GMOCSharpCOM/GMOAllocator.dll
No comments:
Post a Comment