Monday, December 14, 2009

InvalidComObjectException in UT

0 comments

If you are accessing COM server from UT in Visual Studio 2008 and get InvalidComObjectException exception.

Then try changing your TestRunConfig.testrunconfig:

image

 

add this line: <ExecutionThread apartmentState="MTA" />

Tuesday, December 1, 2009

MSXML2.DOMDocument.selectNodes vs. XDocument.Descendants

1 comments
OLD MSXML way:
MSXML2.DOMDocument xmlDoc = new MSXML2.DOMDocument();
MSXML2.IXMLDOMNodeList xmlList = xmlDoc.documentElement.selectNodes("//MyNodeName”);
 
LINQ way:
XDocument xDoc = XDocument.Parse(batchXML);
IEnumerable<XElement> commands = xDoc.Descendants(XName.Get(“MyNodeName”));

contactID = contactEl.Attribute("conactID").Value;
name = contactEl.Element("FirstName").Value;