Thursday, October 4, 2012

Expando Object

The ExpandoObject class enables you to add and delete members of its instances at run time and also to set and get values of these members.

Creating a dynamic instance:
       dynamic Student = new ExpandoObject();
       Student.ID = 1;
       Student.Name = "John";
Student.Grade = 10;


Creating a nested dynamic instance:
       Student.Addess = new ExpandoObject();
       Student.Addess.City = "London";
       Student.Addess.Country = "UK";
       Student.Addess.StreetNo = 123456;
Dynamically binding an Event
Student.Click += new EventHandler(SampleHandler);
 
private void SampleHandler(object sender, EventArgs e)
{
//throw new NotImplementedException();
}
Pass parameter as dynamic.
public void Write(dynamic Student)
{
//do stuff
}

Tuesday, July 10, 2012

Dynamicly add xsi:schemaLocation="location" to XML

// Comment
//create XML
XmlDocument doc = new XmlDocument();

//header
XmlDeclaration decl = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
doc.AppendChild(decl);

//
doc.Schemas.Add("test:schema:v1", "http://sample.com/schema.xsd");
XmlElement decElem = doc.CreateElement("root");
XmlAttribute attr = doc.CreateAttribute("xsi", "schemaLocation", "http://www.w3.org/2001/XMLSchema-instance");
attr.Value = "test:schema:v1 schema.xsd";
decElem .Attributes.Append(attr);
decElem .SetAttribute("xmlns", "decElem");
doc.AppendChild(docElem);

Friday, March 30, 2012

Can't connect to TFS 2010

I've tried:
  1. Stop Collection / Start Collection
  2. Detach / Attach Collection
  3. IIS Stop, Strat , Reset
  4. Flush DNS
  5. Reinstalled TFS
and nothing worked.

I've checked the port 8080 in windows firewall, and was allowed through the firewall but the rule was set to PUBLIC and the network is PRIVATE. Added "private" to the rule and everything works again.

Friday, March 23, 2012

Error when changing an applications Target Framework from 2.0 to 4.0

I've had a problem with Crystal Reports when changing an applications Target Framework from 2.0 to 4.0 

Error:
Could not load file or assembly 'file:///C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet1\crdb_adoplus.dll' or one of its dependencies. The system cannot find the file specified.

Resolution:
Add the following to app.config:
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime Version="v4.0" sku=".NETFramework, Version=v4.0" />
startup>
 
 
System: VS 2010, Crystal Reports 13, Windows 7 x64