.Net, ASP.Net, C#, VB.net, SQL Server, Xml, CSS, Design Patterns related tips, tricks, code snippets, articles, links, thoughts, etc. from Binu & Subi Thayamkery.

Binu Thayamkery is a seasoned software architect with more than 13 years of experience in developing enterprise grade connected systems using Microsoft Technologies. In his current position as a lead consultant-solution architect with Prudential Financial, he is working on architecture of next generation investment reporting framework using .net 3.5/WCF/AJAX, etc. He holds a Masters Degree in Computer Science from Colorado State University. Subi Thayamkery is an experienced software developer with more than 8 years of developing various application software systems ranging from workflow automation systems to compliance management tools. She currently works as a technology consultant for Prudential Financial where she helps develop a new system for corportate governance department. She holds an Electrical Engineering degree from New Jersey Institute of Technology.

Friday, April 25, 2008

Creating Schema from Xml file

Here is a code snippet that creates a simple schema file from an
Xml file. It uses XmlSchemaInference class (available from .net 2.0+)
to inferschema from an xml file.


        XmlReader reader = XmlReader.Create(@"c:\binu\customer.xml");

        
XmlSchemaSet schemaSet = new XmlSchemaSet();

        
XmlSchemaInference schema = new XmlSchemaInference();



        schemaSet = schema.InferSchema(reader);

        
TextWriter writer = new StreamWriter(@"c:\binu\customer.xsd");

        
foreach (XmlSchema s in schemaSet.Schemas())

        {

            s.Write(writer);

        }




Sample Xml file used:


<Customers>

<
Customer CustomerName="Maria Anders" Country="Germany"/>

<
Customer CustomerName="Ana Trujillo" Country="Russia"/>

<
Customer CustomerName="Antonio Moreno" Country="Spain"/>

<
Customer CustomerName="Thomas Hardy" Country="United Kingdom"/>

<
Customer CustomerName="Maria Anders" Country="Holand"/>

<
Customer CustomerName="Christina Berglund" Country="Sweden"/>

</
Customers>




Output:


<?xml version="1.0" encoding="utf-8"?>

<
xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <
xs:element name="Customers">

    <
xs:complexType>

      <
xs:sequence>

        <
xs:element maxOccurs="unbounded" name="Customer">

          <
xs:complexType>

            <
xs:attribute name="CustomerName" type="xs:string" use="required" />

            <
xs:attribute name="Country" type="xs:string" use="required" />

          </
xs:complexType>

        </
xs:element>

      </
xs:sequence>

    </
xs:complexType>

  </
xs:element>

</
xs:schema>


Happy coding!
Cheers!

Tuesday, April 22, 2008

Framework 3.5/VS 2008 web.config

If you are new to Visual Studio 2008 (Framework 3.5), first thing you will notice is that there are lot of new stuff in the web.config file by default.
I found a useful article from 4GuysFromRolla on this, check it out !
Link to article

Cheers

ASP.Net-Crystal Reports Application Deployment

If you are trying to deploy ASP.Net/Crystal Application (I was using VS 2008) and
got errors while running your app, here is something to look for;

1) If you are getting errors, saying "failed to load" some Crystal Assemblies, reasonmight be that you do not have the right Crystal Run time installed in your server.
Crystal Runtime comes with Visual Studio 2008, and you can locate that in the machine
you have installed VS 2008. Path is C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\CrystalReports10_5\CRRedist2008_x86.msi

If you have Visual Studio 2005, you can find the runtime installer in
C:\Program Files\Microsoft Visual Studio 8\Crystal Reports\CRRedist\X64\CRRedist2005_X64.msi

2) Once you have successfully installed runtime and run your application, if you get an error saying "load report failed"...permissions are usually the culprit. Give IIS_WPG group read-write permissions on TEMP directory on your server (check your environment settigs to see where your TEMP is defined)
This is true even if you are impersonating an id to run your application and not using Network Service/ASPNET accounts to run.


Cheers