It seems that this problem has been resolved. After I setup the service pack for .net framework version 1.1,everything thing seems Okay. Thanks! Enjoy!:laugh:
zengkun
Posts
-
A problem about STA object that is stored in Session State -
A problem about STA object that is stored in Session StateHi! First,I write a class with C#.The class looks like this class CSharpClass { //class_imported_from_typelibrary is a coclass that imported from //the typelibrary using Tlbimp.exe //all interfaces of this coclass are derived from IUnknown class_imported_from_typelibrary m_comclass; //CSharpClassA and CSharpClassB are two classes written in C# CSharpClassA m_a; CSharpClassB m_b; …… …… } I use this CSharpClass in my ASP.NET project later.The code in Page_Load function looks like this: Page_Load() { private CSharpClass m_SharpClass; if(Session["MyObj"] == null) { m_SharpClass = new csharpclass(); m_SharpClass.Dosomething(); Session["MyObj"] = m_SharpClass } else { m_SharpClass = (csharpclass)Session["MyObj"]; m_SharpClass.Dosomething(); } } After I retrieve the m_SharpClass from Session state,using this statement(m_SharpClass = (csharpclass)Session["MyObj"]).I found that the two fields m_a and m_b in the m_SharpClass object are OK,but m_comclass is corrupted,from the "Watch Window" it's value is an InvalidCastException.I don't know why? How can I gain access to the STA object after store it in the Session State later? I have set the AspCompat attribute to true. Thank you for your reply!;P
-
A simple question about MSXMLThank you for your help! This question has been resolved:laugh:.
-
A simple question about MSXMLI want to use MSXML to create a XML file like this Here is my source coede #include #import using namespace MSXML2; int main(int argc, char* argv[]) { IXMLDOMDocument2Ptr pXMLDom; HRESULT hr; CoInitialize(NULL); hr = pXMLDom.CreateInstance(__uuidof(DOMDocument40)); if (FAILED(hr)) { printf("Failed to CreateInstance on an XML DOM"); return NULL; } pXMLDom->preserveWhiteSpace = VARIANT_TRUE; IXMLDOMProcessingInstructionPtr pi; pi = pXMLDom->createProcessingInstruction("xml", "version='1.0' encoding='UTF-8'"); if (pi != NULL) { pXMLDom->appendChild(pi); pi.Release(); } IXMLDOMElementPtr pe; IXMLDOMNodePtr nodePtr; _variant_t varTyp((short)NODE_ELEMENT); nodePtr=pXMLDom->createNode(varTyp,"Schema","http://www.w3.org/2001/XMLSchema"); pXMLDom->appendChild(nodePtr); nodePtr.Release(); pe = pXMLDom->documentElement; IXMLDOMAttributePtr pa; pXMLDom->documentElement->appendChild(pXMLDom->createTextNode("\n\t")); IXMLDOMDocumentFragmentPtr pdf; pdf = pXMLDom->createDocumentFragment(); pe = pXMLDom->createElement("element"); pe->setAttribute("name","Features"); pe->setAttribute("type","wfs:featuresType"); pe->setAttribute("substitutionGroup","gml:_FeatureCollection"); pdf->appendChild(pe); pe.Release(); pXMLDom->documentElement->appendChild(pdf); pdf.Release(); pXMLDom->documentElement->appendChild(pXMLDom->createTextNode("\n\t")); hr = pXMLDom->save("dynaDom.xml"); if (FAILED(hr)) { printf("Failed to save DOM to dynaDom.xml\n"); } else { printf("DOM saved to dynamDom.xml\n"); } if (pXMLDom) pXMLDom.Release(); CoUninitialize(); return 0; } But the output is: you can see that :there is an attribute "xmlns" within the "element" tag and the value of the attribute is nothing. I don't want the out come is this,Please Help!