Skip to main content
GameDev.net gamedev.net
🔒 Locked

XML parser problems

Started by Tang of the Mountain Sep 11, 2006 at 2:29 PM 9 replies 2.6k views
Original Post
Tang of the Mountain
Tang of the Mountain
Ok, so i have a SAXXML parser I made. I use it on one computer and it works just fine. Every time. I bring the EXACT code over to a separate computer and its new purpose is apparently to curl into a ball and whimper before promptly dying. Causing an memory reading exception. The computers have the same version of .NET, the same OS, the same code, totally different result. I never get to parse the file or even load it as the reader is broke. The code below is where i break:

void CXMLParser::LoadXMLMap(char *szFile)
{
	ISAXXMLReader		*pReader = NULL;
	wchar_t				wcBuffer[1024];

	// COM Setup
	CoInitialize(NULL);
	CoCreateInstance(__uuidof(SAXXMLReader40), NULL, CLSCTX_ALL, __uuidof(ISAXXMLReader), (void**)&pReader);

	pReader->putContentHandler(this);  //ON THIS LINE IS WHERE I CRASH!!

	// Build wchar string of file and start parsing
	mbstowcs(wcBuffer, szFile, 1023);
	pReader->parseURL(wcBuffer);
	pReader->Release();

	CoUninitialize();
}

I crash because pReader is NULL after it was just "created" so CoCreateInstance() is clearly failing in its one purpose. Anyone have any idea as to what I could be forgetting to do(which is most likely the case) or maybe something I may have overlooked? Any help is greatly appreciated.
We have youth, how about a fountain of smart.e4 e5 f4 d5
reana1
reana1
Did you set any compiler options in the original IDE that you forgot on the second machine?
Tadd- WarbleWare
Tang of the Mountain
Tang of the Mountain
I havent set anything accept for an extra lib include (ole32.lib) which is linked in both, as well as UUlid.lib for the sake of being thorough.

Other than that no actual options had to be set and nothing else that wasnt just written in code.
We have youth, how about a fountain of smart.e4 e5 f4 d5
Caramelo
Caramelo
Did you check what CoCreateInstance() returns ?
HRESULT hr = CoCreateInstance()

You might also try using Smart pointers instead i.e.



try
{
ISAXXMLReaderPtr spReader(__uuidof(SAXXMLReader40));

...
}
catch(_com_error &e)
{
{
printf("Error\n");
printf("\a\tCode = %08lx\n", e.Error());
printf("\a\tCode meaning = %s", e.ErrorMessage());

_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
printf("\a\tSource = %s\n", (LPCSTR) bstrSource);
printf("\a\tDescription = %s\n", (LPCSTR) bstrDescription);

}



And finally check if both computers have MSXML 4.0 installed !?

There's always hell using msxml, you know ;]
.
Morpheus011
Morpheus011
often times there is a need to use SAXXMLReader instead of SAXXMLReader40 when you call CoCreateInstance(); I can't remember why one works sometimes and sometimes the other does...anyone have some insight as to when one works over the other?

Try changing that on the machine it's not working on and see if it works.
paulecoyote
paulecoyote
If it's Dot Net based, make sure you've regasm'd your parser so your COM stuff can use your .Net assembly.
Anything posted is personal opinion which does not in anyway reflect or represent my employer. Any code and opinion is expressed “as is” and used at your own risk – it does not constitute a legal relationship of any kind.
Tang of the Mountain
Tang of the Mountain
Thanks for the input Ill try those out to day and let you know what comes of it...

Quote:
Original post by paulecoyote
If it's Dot Net based, make sure you've regasm'd your parser so your COM stuff can use your .Net assembly.



regasm?

We have youth, how about a fountain of smart.e4 e5 f4 d5
Tang of the Mountain
Tang of the Mountain
So, as it turns out, SAXXMLReader40 being changed to SAXXMLReader worked just fine. Any idea as to why this is the case?
We have youth, how about a fountain of smart.e4 e5 f4 d5
Tang of the Mountain
Tang of the Mountain
Quote:
Original post by Tang of the Mountain
So, as it turns out, SAXXMLReader40 being changed to SAXXMLReader worked just fine. Any idea as to why this is the case?




CoCreateInstance(__uuidof(SAXXMLReader40), NULL, CLSCTX_ALL, __uuidof(ISAXXMLReader), (void**)&pReader);////changed to this: //CoCreateInstance(__uuidof(SAXXMLReader), NULL, CLSCTX_ALL, __uuidof(ISAXXMLReader), (void**)&pReader);
We have youth, how about a fountain of smart.e4 e5 f4 d5
Caramelo
Caramelo
I suppose you have included these...

#import
#include


Anyway, I'm really not sure why this happens, come to think of it - I've always used ISAXXMLReader . :-)

Maybe you can check this place for info.
.
paulecoyote
paulecoyote
Quote:
Original post by Tang of the Mountain
So, as it turns out, SAXXMLReader40 being changed to SAXXMLReader worked just fine. Any idea as to why this is the case?


Depends on the classes / interfaces that were registered with COM.

yar, regasm to register classes with COM. I think gacutil might be able to do it too - though that is more for .Net assemblies using other .Net assemblies.
Anything posted is personal opinion which does not in anyway reflect or represent my employer. Any code and opinion is expressed “as is” and used at your own risk – it does not constitute a legal relationship of any kind.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.