Friday, 6 November 2009
Service factory
Thursday, 19 March 2009
Accessing TFS programmatically result in a Common Language Runtime detected an invalid program.
I have written a small application which access TFS programmatically to carry out certain operation (I won’t go in detail about the application, everything worked fine on my local machine but when I deployed this application onto SYST Environment, my really sweet application was throwing following error (haven’t included the stacktrace though).
Error Details: InvalidProgramException: Common Language Runtime detected an invalid program.
Reading thru some of the forums indicated one of the possibility of this might be if server is running 64 Bit. In my case this was not a problem as my server is 32 bit. I was able to resolve this issue by installing VS2008TeamExplorer on the server. Not sure how this makes a difference as all required dll’s for accessing TFS programmatically is included in the BIN directory of application. If any of you have any further info on these lines please leave a comment.
Friday, 20 February 2009
Unable to start debugging on the web server. An authentication error occurred while communicating with the web server. Please see Help for assistance
when I was trying to debug a website with host header, was getting an authentication error message, after much of googleing I couldn’t find a solution to this problem until one of my colleague pointed me to the MSDN Blog where Joe Cartano has blogged about this solution. He also explains the cause for this problem. Click here( Visual Web Developer Team Blog ) to go this blog
Tuesday, 10 February 2009
Validate XML with XSD in .Net 3.5
In days on .Net 2.0, its was not straight forward to validate and XML with XSD. We were doing lot of coding playing around with XmlTextReader and XmlValidatingReader. Thanks to .Net 3.5 where majority of the functionality is provided by the XMLDocument itself. Below is the piece of code to validate and XML document against XSD.
Below is the event handler to handle the validation event, we need to add this to the event handler collection, this becomes the input parameter for validate function.
protected void ValidationHandler(object sender,
ValidationEventArgs args)
{
// code you want to execute when validation error/warning is raised
ErrorMessage += "
" + args.Message + "\r\n";
ErrorsCount++;
}
Below is the code snippet to validate the xml against XSD, below snippet assumes that XSD file resides in the same folder as XML.
XmlDocument xx = new XmlDocument();
xx.Load(xmlFilePath);
xx.Schemas.Add("",Path.Combine(Path.GetDirectoryName(xmlFilePath),
"ConfigurationSchema.xsd"));
// create an eventhandler with function coded above
ValidationEventHandler eventHandler = new ValidationEventHandler(ValidationHandler);
//Validate the XML
xx.Validate(eventHandler);
validation event is raised for every error/waring while validating, so you can process each error message separately as required