XML File laden/schließen -> Unhandled exception



  • Hi,

    wenn ich mein Programm nach Ausführen der folgenden Funktion schließe, tritt eine Unhandled exception auf.

    //header file protected area: 
    MSXML2::IXMLDOMDocument2Ptr m_pXMLDoc; 
    MSXML2::IXMLDOMElementPtr m_pDocRoot;
    
    //cpp file
    
    // Create the XML Document	
    
    	HRESULT hr = m_pXMLDoc.CreateInstance(CLSID_DOMDocument);
    	if (FAILED(hr))
    	{
    		_com_error er(hr);
    		AfxMessageBox(er.ErrorMessage());
    		return FALSE; 
    	}
    
    	// convert xml file name string to something COM can handle (BSTR)
    	_bstr_t bstrFileName;
    	bstrFileName = strFileName.AllocSysString();
    	XmlFileName = strFileName; 
    
    	// call the IXMLDOMDocumentPtr's load function to load the XML document
    	variant_t vResult;
    	vResult = m_pXMLDoc->load(bstrFileName);
    	if (((bool)vResult) == TRUE) // success!
    	{// now that the document is loaded, we need to initialize the root pointer		
    		m_pDocRoot = m_pXMLDoc->documentElement;
    	}
    	else
    	{
    		AfxMessageBox(_T("XML File FAILED to load!"));
    		return FALSE;
    	}
    
             //xml file releasen 
    	m_pXMLDoc->Release();
    

    Unhandeld exception in comip.h

    void _Release() throw()
        {
            if (m_pInterface != NULL) 
            {
                /* !!!! exception bei release() !!!!! */
                m_pInterface->Release();
            }
        }
    

    Diese Exception tritt dann auf, wenn ich das Fenster über das Kreuzchen rechts oben versuche zu schließen.

    Gruß
    Harald



  • bin bei meiner Recherche etwas weiter gekommen. Wenn ich die beiden

    MSXML2::IXMLDOMDocument2Ptr m_pXMLDoc; 
    MSXML2::IXMLDOMElementPtr m_pDocRoot;
    

    in der cpp-Methode installiere, bekomme ich keine Fehlermeldung.

    Daher hier mal einen kurzen Ausschnitt der Klassendefinition:

    class CXmlFile : 
    	public CProperty
    {
    public:
    	CXmlFile(void);
    	~CXmlFile(void);
    
    public:
    	virtual BOOL SetData(CStringList &slist); 
    	virtual CString GetValue(const CString & name, const UINT & number); 
    	virtual CString GetAttribute(const CString & key, const UINT & number, const CString & attribute); 
    
    protected:
    
    	MSXML2::IXMLDOMDocument2Ptr m_pXMLDoc; 
    	MSXML2::IXMLDOMElementPtr m_pDocRoot;
    };
    

    und die CProperty Class

    class CProperty
    {
    public:
    	CProperty(); 
    	~CProperty();
    
    public:	
    	virtual CString GetValue(const CString & name, const UINT & number); 
    	virtual CString GetAttribute(const CString & key, const UINT & number, const CString & attribute); 
    	virtual BOOL SetData(CStringList &slist); 
    };
    

    Alle virtuellen Methoden dieser Klasse sind auch in der XML-File Klasse vorhanden.



  • Was bedeutet denn in der cpp-Methode installiere? 🕶


Anmelden zum Antworten