G
Guest
Hi,
I am new to C++ & MC++. I am trying to write a wrapper class for exsiting
code which uses libraries(Adobe Framemaker) to open documents. These
libraries are written in C++.
The code is :-
.......
public __gc class Framemaker
{
bool ConnectToFrameSession(String* strProgID)
{
char* strProg = (char*)(void*)Marshal::StringToHGlobalAnsi(strProgID);
ConnectToFrame(strProg);
return true;
}
.......
int ConnectToFrame(char *strProg)
{
StringT opt_progid;
CLSID pclsid;
LPOLESTR progStr;
HRESULT res;
F_ObjHandleT docId;
// Get the process name.
opt_progid = F_StrCopyString((StringT)strProg);
// Convert the process name into a GUID
progStr = (OLECHAR*)malloc( WBUFLEN*sizeof(wchar_t) );
if(0 == MultiByteToWideChar(CP_ACP, 0, (char *)opt_progid, -1, progStr,
WBUFLEN ))
{
fprintf(stderr, "failed to allocate\n");
return(1);
}
........
Now the code bombs while doing a malloc or calling any native frame
functions in the function above. It says Object Not Set or NullRefernecce
Exception.
Is it beacuse i am trying to mix managed and unmanaged code?
How shld i go abt solving ths problem ?
Also this code runs fine if i make a console application & run it.
I am trying to make wrapper dll which would be calkled by C#.
Only differnec i see is __GC.
Pls guide me.
Thanks,
Gurminder
I am new to C++ & MC++. I am trying to write a wrapper class for exsiting
code which uses libraries(Adobe Framemaker) to open documents. These
libraries are written in C++.
The code is :-
.......
public __gc class Framemaker
{
bool ConnectToFrameSession(String* strProgID)
{
char* strProg = (char*)(void*)Marshal::StringToHGlobalAnsi(strProgID);
ConnectToFrame(strProg);
return true;
}
.......
int ConnectToFrame(char *strProg)
{
StringT opt_progid;
CLSID pclsid;
LPOLESTR progStr;
HRESULT res;
F_ObjHandleT docId;
// Get the process name.
opt_progid = F_StrCopyString((StringT)strProg);
// Convert the process name into a GUID
progStr = (OLECHAR*)malloc( WBUFLEN*sizeof(wchar_t) );
if(0 == MultiByteToWideChar(CP_ACP, 0, (char *)opt_progid, -1, progStr,
WBUFLEN ))
{
fprintf(stderr, "failed to allocate\n");
return(1);
}
........
Now the code bombs while doing a malloc or calling any native frame
functions in the function above. It says Object Not Set or NullRefernecce
Exception.
Is it beacuse i am trying to mix managed and unmanaged code?
How shld i go abt solving ths problem ?
Also this code runs fine if i make a console application & run it.
I am trying to make wrapper dll which would be calkled by C#.
Only differnec i see is __GC.
Pls guide me.
Thanks,
Gurminder