Monthly Archives: July 2010

Serialize the Data to XML

public static String SerializeInterface(object SerializedObject)
       {
           using (MemoryStream stream = new MemoryStream())
           {
               XmlSerializer serializer = null;
               if (SerializedObject.GetType() == typeof(INTERFACE_ERRORS))
               {
                   serializer = new XmlSerializer(typeof(INTERFACE_ERRORS));
                   INTERFACE_ERRORS o = (INTERFACE_ERRORS)SerializedObject;
                   serializer.Serialize((Stream)stream, o);
               }
               else if (SerializedObject.GetType() == typeof(DETAILS_TO_SUB_SYSTEM))
               {
                   serializer = new XmlSerializer(typeof(DETAILS_TO_SUB_SYSTEM));
                   DETAILS_TO_SUB_SYSTEM details_to_sub_system = (DETAILS_TO_SUB_SYSTEM)SerializedObject;
                   serializer.Serialize((Stream)stream, details_to_sub_system);
               }

               stream.Seek(0L, SeekOrigin.Begin);
               byte[] buffer = new byte[stream.Length];
               int count = stream.Read(buffer, 0, 20);
               while (count < stream.Length)
               {
                   buffer[count++] = Convert.ToByte(stream.ReadByte());
               }

               char[] chars = new char[Encoding.UTF8.GetCharCount(buffer, 0, count)];
               Encoding.UTF8.GetDecoder().GetChars(buffer, 0, count, chars, 0);
               return new string(chars);
           }
       }

How to create bootable VHD – Windows 7 or Windows 2008 R2

 

The below steps shows how to create a bootable VHD install for Windows 7 or Windows 2008 R2. With this step x64 OS can be installed, but requires a VT enabled machine in the BIOS.

1. Insert the Bootable Install DVD to the drive[Windows 7 or Windows 2008 R2]

2. Restart the machine, make sure the boot order is to DVD first in the BIOS to boot in DVD.

3. Once the windows is loaded, Select next in the Language selection screen

4. In the Install Now screen, Press Shift+F10 to enter into the command prompt

5. Type Diskpart and Enter

6. Type Create vdisk file=”c:\vhd\win7x64.vhd” type=expandable maximum=<vhd size in MB>

7. For differencing vhd shd add the parent=”VHD path” in the above command (optional)

8. Press Enter and Type Select vdisk file=”c:\vhd\win7x64.vhd”

9. Type attach vdisk

10. Press Alt+Tab

11. Now click on the Install Now Button

12. In the Drives windows select the virtual disk which we created, usually will be at the last. Ignore the warning which appears at the bottom.

13. Done, then follow the wizard to finish installation.

XSD.exe Class Generate Error – Datatype missing for sqltypes

 

Select *  FROM dbo.aspnet_applications  FOR XML AUTO, XMLSCHEMA

The xsd generated from sql using the following query(aspnet_applications is the table name) will have the sqltypes imported in the schema. If we use the xsd command line tool to generate a cs class the xsd will through the exception

Error: Error generating classes for schema ‘aspnet_applications’.
  – The datatype ‘
http://schemas.microsoft.com/sqlserver/2004/sqltypes:nvarchar’
is missing.”

If we look at the xsd generated by sql the namespace will point to the sqltypes.xsd uri which xsd.exe could not resolve.

—————–XSD Generated By SQL ————–

<xsd:schema targetNamespace="urn:schemas-microsoft-com:sql:SqlRowSet1" xmlns:schema="urn:schemas-microsoft-com:sql:SqlRowSet1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sqltypes="http://schemas.microsoft.com/sqlserver/2004/sqltypes" elementFormDefault="qualified">
  <xsd:import namespace="http://schemas.microsoft.com/sqlserver/2004/sqltypes" schemaLocation="http://schemas.microsoft.com/sqlserver/2004/sqltypes/sqltypes.xsd" />
  <xsd:element name="AETSMiMgmtDev.dbo.aspnet_Applications">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="ApplicationName">
          <xsd:simpleType>
            <xsd:restriction base="sqltypes:nvarchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreNonSpace IgnoreKanaType IgnoreWidth">
              <xsd:maxLength value="256" />
            </xsd:restriction>
          </xsd:simpleType>
        </xsd:element>
        <xsd:element name="LoweredApplicationName">
          <xsd:simpleType>
            <xsd:restriction base="sqltypes:nvarchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreNonSpace IgnoreKanaType IgnoreWidth">
              <xsd:maxLength value="256" />
            </xsd:restriction>
          </xsd:simpleType>
        </xsd:element>
        <xsd:element name="ApplicationId" type="sqltypes:uniqueidentifier" />
        <xsd:element name="Description" minOccurs="0">
          <xsd:simpleType>
            <xsd:restriction base="sqltypes:nvarchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreNonSpace IgnoreKanaType IgnoreWidth">
              <xsd:maxLength value="256" />
            </xsd:restriction>
          </xsd:simpleType>
        </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>

———————END——————

To solve this issue i modified the xsd to include the xsd in the local directory. I navigated to the URL “http://schemas.microsoft.com/sqlserver/2004/sqltypes/sqltypes.xsd” , downloaded the full xsd and saved the file as sqltypes.xsd

After saving the sqltypes in a seperate xsd, i modified the original aspnet_applications.xsd like below

—————–Modified XSD to work for xsd.exe————

<xsd:schema targetNamespace="http://schemas.microsoft.com/sqlserver/2004/sqltypes" xmlns="Subscribers"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:sqltypes="http://schemas.microsoft.com/sqlserver/2004/sqltypes"
            elementFormDefault="qualified">
  <xsd:include schemaLocation="sqltypes.xsd" />
  <xsd:element name="aspnet_Applications">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="ApplicationName">
          <xsd:simpleType>
            <xsd:restriction base="sqltypes:nvarchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreNonSpace IgnoreKanaType IgnoreWidth">
              <xsd:maxLength value="256" />
            </xsd:restriction>
          </xsd:simpleType>
        </xsd:element>
        <xsd:element name="LoweredApplicationName">
          <xsd:simpleType>
            <xsd:restriction base="sqltypes:nvarchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreNonSpace IgnoreKanaType IgnoreWidth">
              <xsd:maxLength value="256" />
            </xsd:restriction>
          </xsd:simpleType>
        </xsd:element>
        <xsd:element name="ApplicationId" type="sqltypes:uniqueidentifier" />
        <xsd:element name="Description" minOccurs="0">
          <xsd:simpleType>
            <xsd:restriction base="sqltypes:nvarchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreNonSpace IgnoreKanaType IgnoreWidth">
              <xsd:maxLength value="256" />
            </xsd:restriction>
          </xsd:simpleType>
        </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>

——————————END————-

The modified tag is in red bold color. Remember the downloaded sqltypes.xsd is in the same directory as the aspnet_applications.xsd
Now if we run xsd.exe aspnet_applications.xsd /c

the class generation will be successful

403.1 HTTP ERROR XAP File for SharePoint 2007

This error occurred for me when i try to consume silver light xap files deployed in the /_CONTROLTEMPLATES/XAPS/ directory. The problem occurs when i had Windows 2008 server with IIS 7.0 and SharePoint 2007 is installed.

Even when a MIME entry is added to the IIS 7.0 the problem is still the same. The MIME entry for Silverlight is added by default by Windows 2008 server.

Resolution

In IIS 7.0 navigate to the site, Right click and select  “Features View”. On the right Pane select Handler Mappings, select the AboMapperCustom-n handler entry and on the right side of the pane click “Edit Feature Permissions…” from the Actions menu area. Place a check mark against Script and Execute, click Ok. Now it should work

This Site, This List SharePoint Search not working or Returns nothing

This issue was killing me for long time, i searched through bing and found out that issue with the AAM settings.

The Alternate Access Mapping default URL should match with the url which you are trying to Crawl in the SPP search Settings Page. Initially the solution was not working, i stopped the Search service, reset the crawled content and changed the AAM settings it worked.

If that is not working can try replace the _/layouts/OSSSearch.aspx to wss search page.

WCF Service – A name was started with an invalid character. Error processing resource

Error Details:

The XML page cannot be displayed

Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


A name was started with an invalid character. Error processing resource

http://SENWIN2008/WCF/Service/’

<%@ ServiceHost Language="C#" Debug="true" Service="Service Name" CodeBehind="Service.svc.cs" %>

Resolution

  1. Check whether the IIS site is configured for .NET 2.0, in the ASP.NET tab of the properties, in some cases the ASP.NET will be 1.1 reference.
  2. If the above is not solved, may be the order of installation of .NET is wrong. Always need to install IIS and then .NET 3.5. If thats the case run the ServiceModelReg.exe from the framework folder this should solve the issue.