S
sklett
STILL trying to wrap an unmanaged C++ class that is itself a wrapper to some
COM stuff, not sure, it is littered with LPDISPATCH and InvokeHelper, etc.
Problem is, when something goes wrong, I'm having a hard time debugging.
In my managed C++ class(the one wrapping the unmanaged C++) I have a method
that looks like this:
bool FindFileItem(String* filename, IVSSItem& founditem);
that method calls the unmanaged method:
bool FindFileItem(PCSTR filename, IVSSItem& founditem);
identical. When I call the managed method from my C# code, the IVSSItem&
reference is a pointer (intellisense says that I need to specify a
IVSSItem*)
I suspect somewhere in here is where my crash is originating. I can avoid
the crash by created an IVSSItem object in the body of my unmanaged method
and assign to it rather than the IVSSItem reference.
I really am in over my head. Once I get this wrapper class to behave, I can
move past all this and get back to C# only, but for now I'm stuck here.
Does anyone have any clues or hints for me?
Thanks for any help.
Just in case, I have posted the relevant code below:
------- C# code that calls managed C++ wrapper class --------
private bool AssetExists(string extension, ref string filename)
{
unsafe
{
IVSSItem item;
if(sourceSafe.FindFileItem(filePath, &item) == true)
{
return true;
}
}
return false;
}
------ Managed C++ code that wraps the unmanaged C++ code -------
bool CSUSSWrapper::FindFileItem(String* filename, IVSSItem& founditem)
{
char* pFilename =
(char*)(void*)Marshal::StringToHGlobalAnsi(filename);
bool result = m_objSourceSafe->FindFileItem(pFilename, founditem);
Marshal::FreeHGlobal(pFilename);
return result;
}
COM stuff, not sure, it is littered with LPDISPATCH and InvokeHelper, etc.
Problem is, when something goes wrong, I'm having a hard time debugging.
In my managed C++ class(the one wrapping the unmanaged C++) I have a method
that looks like this:
bool FindFileItem(String* filename, IVSSItem& founditem);
that method calls the unmanaged method:
bool FindFileItem(PCSTR filename, IVSSItem& founditem);
identical. When I call the managed method from my C# code, the IVSSItem&
reference is a pointer (intellisense says that I need to specify a
IVSSItem*)
I suspect somewhere in here is where my crash is originating. I can avoid
the crash by created an IVSSItem object in the body of my unmanaged method
and assign to it rather than the IVSSItem reference.
I really am in over my head. Once I get this wrapper class to behave, I can
move past all this and get back to C# only, but for now I'm stuck here.
Does anyone have any clues or hints for me?
Thanks for any help.
Just in case, I have posted the relevant code below:
------- C# code that calls managed C++ wrapper class --------
private bool AssetExists(string extension, ref string filename)
{
unsafe
{
IVSSItem item;
if(sourceSafe.FindFileItem(filePath, &item) == true)
{
return true;
}
}
return false;
}
------ Managed C++ code that wraps the unmanaged C++ code -------
bool CSUSSWrapper::FindFileItem(String* filename, IVSSItem& founditem)
{
char* pFilename =
(char*)(void*)Marshal::StringToHGlobalAnsi(filename);
bool result = m_objSourceSafe->FindFileItem(pFilename, founditem);
Marshal::FreeHGlobal(pFilename);
return result;
}