C:\temp2\tester\Then save the following files in that folder. The open the project in VS2005 and build it. Run it and you'll see what I mean.
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.50727</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{8F4AB357-49E6-4575-8478-94B0264987F9}</ProjectGuid> <OutputType>Exe</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>Tester</RootNamespace> <AssemblyName>Tester</AssemblyName> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Runtime.Remoting" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="Program.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="test.cs" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> </Project>Save below as program.cs
using System; using System.Text; using System.IO; using System.Data; using System.Xml; using Tester; using System.Runtime.Remoting.Metadata.W3cXsd2001; namespace Tester { public class Demo { public static void Main(string[] args) { Assignments myDataSet = new Assignments(); myDataSet.ReadXml("c:\\temp2\\test.xml",XmlReadMode.Auto); SoapHexBinary hexBinary = new SoapHexBinary(myDataSet.Assignment[0].Payload); // Print the value of the SoapHexBinary object in XSD format. Console.WriteLine("The SoapHexBinary object in XSD format is {0}.", hexBinary.ToString()); Console.WriteLine(); // Print the XSD type string of this particular SoapHexBinary object. Console.WriteLine( "The XSD type of the SoapHexBinary object is {0}.", hexBinary.GetXsdType()); // Print the value of the SoapHexBinary object. Console.Write("hexBinary.Value contains:"); Console.Write(hexBinary.ToString()); Console.WriteLine(); Console.WriteLine(); for (int i = 0; i < hexBinary.Value.Length; ++i) { Console.Write(" " + hexBinary.Value[i]); } Console.WriteLine(); // Print the XSD type string of the SoapHexBinary class. Console.WriteLine(); Console.WriteLine("The XSD type of the class SoapHexBinary is {0}.", SoapHexBinary.XsdType); } } }Save below as test.cs, this is the dataset class:
//------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:2.0.50727.42 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ using System; namespace Tester { // // This source code was auto-generated by xsd, Version=2.0.50727.42. // [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] [Serializable()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.ComponentModel.ToolboxItem(true)] [System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedDataSetSchema")] [System.Xml.Serialization.XmlRootAttribute("Assignments")] [System.ComponentModel.Design.HelpKeywordAttribute("vs.data.DataSet")] public partial class Assignments : System.Data.DataSet { private AssignmentDataTable tableAssignment; private System.Data.SchemaSerializationMode _schemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema; [System.Diagnostics.DebuggerNonUserCodeAttribute()] public Assignments() { this.BeginInit(); this.InitClass(); System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged); base.Tables.CollectionChanged += schemaChangedHandler; base.Relations.CollectionChanged += schemaChangedHandler; this.EndInit(); } [System.Diagnostics.DebuggerNonUserCodeAttribute()] protected Assignments(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context, false) { if ((this.IsBinarySerialized(info, context) == true)) { this.InitVars(false); System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler1 = new System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged); this.Tables.CollectionChanged += schemaChangedHandler1; this.Relations.CollectionChanged += schemaChangedHandler1; return; } string strSchema = ((string)(info.GetValue("XmlSchema", typeof(string)))); if ((this.DetermineSchemaSerializationMode(info, context) == System.Data.SchemaSerializationMode.IncludeSchema)) { System.Data.DataSet ds = new System.Data.DataSet(); ds.ReadXmlSchema(new System.Xml.XmlTextReader(new System.IO.StringReader(strSchema))); if ((ds.Tables["Assignment"] != null)) { base.Tables.Add(new AssignmentDataTable(ds.Tables["Assignment"])); } this.DataSetName = ds.DataSetName; this.Prefix = ds.Prefix; this.Namespace = ds.Namespace; this.Locale = ds.Locale; this.CaseSensitive = ds.CaseSensitive; this.EnforceConstraints = ds.EnforceConstraints; this.Merge(ds, false, System.Data.MissingSchemaAction.Add); this.InitVars(); } else { this.ReadXmlSchema(new System.Xml.XmlTextReader(new System.IO.StringReader(strSchema))); } this.GetSerializationData(info, context); System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged); base.Tables.CollectionChanged += schemaChangedHandler; this.Relations.CollectionChanged += schemaChangedHandler; } [System.Diagnostics.DebuggerNonUserCodeAttribute()] [System.ComponentModel.Browsable(false)] [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)] public AssignmentDataTable Assignment { get { return this.tableAssignment; } } [System.Diagnostics.DebuggerNonUserCodeAttribute()] [System.ComponentModel.BrowsableAttribute(true)] [System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Visible)] public override System.Data.SchemaSerializationMode SchemaSerializationMode { get { return this._schemaSerializationMode; } set { this._schemaSerializationMode = value; } } [System.Diagnostics.DebuggerNonUserCodeAttribute()] [System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)] public new System.Data.DataTableCollection Tables { get { return base.Tables; } } [System.Diagnostics.DebuggerNonUserCodeAttribute()] [System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)] public new System.Data.DataRelationCollection Relations { get { return base.Relations; } } [System.Diagnostics.DebuggerNonUserCodeAttribute()] protected override void InitializeDerivedDataSet() { this.BeginInit(); this.InitClass(); this.EndInit(); } [System.Diagnostics.DebuggerNonUserCodeAttribute()] public override System.Data.DataSet Clone() { Assignments cln = ((Assignments)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return cln; } [System.Diagnostics.DebuggerNonUserCodeAttribute()] protected override bool ShouldSerializeTables() { return false; } [System.Diagnostics.DebuggerNonUserCodeAttribute()] protected override bool ShouldSerializeRelations() { return false; } [System.Diagnostics.DebuggerNonUserCodeAttribute()] protected override void ReadXmlSerializable(System.Xml.XmlReader reader) { if ((this.DetermineSchemaSerializationMode(reader) == System.Data.SchemaSerializationMode.IncludeSchema)) { this.Reset(); System.Data.DataSet ds = new System.Data.DataSet(); ds.ReadXml(reader); if ((ds.Tables["Assignment"] != null)) { base.Tables.Add(new AssignmentDataTable(ds.Tables["Assignment"])); } this.DataSetName = ds.DataSetName; this.Prefix = ds.Prefix; this.Namespace = ds.Namespace; this.Locale = ds.Locale; this.CaseSensitive = ds.CaseSensitive; this.EnforceConstraints = ds.EnforceConstraints; this.Merge(ds, false, System.Data.MissingSchemaAction.Add); this.InitVars(); } else { this.ReadXml(reader); this.InitVars(); } } [System.Diagnostics.DebuggerNonUserCodeAttribute()] protected override System.Xml.Schema.XmlSchema GetSchemaSerializable() { System.IO.MemoryStream stream = new System.IO.MemoryStream(); this.WriteXmlSchema(new System.Xml.XmlTextWriter(stream, null)); stream.Position = 0; return System.Xml.Schema.XmlSchema.Read(new System.Xml.XmlTextReader(stream), null); } [System.Diagnostics.DebuggerNonUserCodeAttribute()] internal void InitVars() { this.InitVars(true); } [System.Diagnostics.DebuggerNonUserCodeAttribute()] internal void InitVars(bool initTable) { this.tableAssignment = ((AssignmentDataTable)(base.Tables["Assignment"])); if ((initTable == true)) { if ((this.tableAssignment != null)) { this.tableAssignment.InitVars(); } } } [System.Diagnostics.DebuggerNonUserCodeAttribute()] private void InitClass() { this.DataSetName = "Assignments"; this.Prefix = ""; this.Locale = new System.Globalization.CultureInfo(""); this.EnforceConstraints = true; this.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema; this.tableAssignment = new AssignmentDataTable(); base.Tables.Add(this.tableAssignment); } [System.Diagnostics.DebuggerNonUserCodeAttribute()] private bool ShouldSerializeAssignment() { return false; } [System.Diagnostics.DebuggerNonUserCodeAttribute()] private void SchemaChanged(object sender, System.ComponentModel.CollectionChangeEventArgs e) { if ((e.Action == System.ComponentModel.CollectionChangeAction.Remove)) { this.InitVars(); } } [System.Diagnostics.DebuggerNonUserCodeAttribute()] public static System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(System.Xml.Schema.XmlSchemaSet xs) { Assignments ds = new Assignments(); System.Xml.Schema.XmlSchemaComplexType type = new System.Xml.Schema.XmlSchemaComplexType(); System.Xml.Schema.XmlSchemaSequence sequence = new System.Xml.Schema.XmlSchemaSequence(); xs.Add(ds.GetSchemaSerializable()); System.Xml.Schema.XmlSchemaAny any = new System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; return type; } public delegate void AssignmentRowChangeEventHandler(object sender, AssignmentRowChangeEvent e); [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] [System.Serializable()] [System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedTableSchema")] public partial class AssignmentDataTable : System.Data.DataTable, System.Collections.IEnumerable { private System.Data.DataColumn columnPayload; [System.Diagnostics.DebuggerNonUserCodeAttribute()] public AssignmentDataTable() { this.TableName = "Assignment"; this.BeginInit(); this.InitClass(); this.EndInit(); } [System.Diagnostics.DebuggerNonUserCodeAttribute()] internal AssignmentDataTable(System.Data.DataTable table) { this.TableName = table.TableName; if ((table.CaseSensitive != table.DataSet.CaseSensitive)) { this.CaseSensitive = table.CaseSensitive; } if ((table.Locale.ToString() != table.DataSet.Locale.ToString())) { this.Locale = table.Locale; } if ((table.Namespace != table.DataSet.Namespace)) { this.Namespace = table.Namespace; } this.Prefix = table.Prefix; this.MinimumCapacity = table.MinimumCapacity; } [System.Diagnostics.DebuggerNonUserCodeAttribute()] protected AssignmentDataTable(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context) { this.InitVars(); } [System.Diagnostics.DebuggerNonUserCodeAttribute()] public System.Data.DataColumn PayloadColumn { get { return this.columnPayload; } } [System.Diagnostics.DebuggerNonUserCodeAttribute()] [System.ComponentModel.Browsable(false)] public int Count { get { return this.Rows.Count; } } [System.Diagnostics.DebuggerNonUserCodeAttribute()] public AssignmentRow this[int index] { get { return ((AssignmentRow)(this.Rows[index])); } } public event AssignmentRowChangeEventHandler AssignmentRowChanging; public event AssignmentRowChangeEventHandler AssignmentRowChanged; public event AssignmentRowChangeEventHandler AssignmentRowDeleting; public event AssignmentRowChangeEventHandler AssignmentRowDeleted; [System.Diagnostics.DebuggerNonUserCodeAttribute()] public void AddAssignmentRow(AssignmentRow row) { this.Rows.Add(row); } [System.Diagnostics.DebuggerNonUserCodeAttribute()] public AssignmentRow AddAssignmentRow(byte[] Payload) { AssignmentRow rowAssignmentRow = ((AssignmentRow)(this.NewRow())); rowAssignmentRow.ItemArray = new object[] { Payload}; this.Rows.Add(rowAssignmentRow); return rowAssignmentRow; } [System.Diagnostics.DebuggerNonUserCodeAttribute()] public virtual System.Collections.IEnumerator GetEnumerator() { return this.Rows.GetEnumerator(); } [System.Diagnostics.DebuggerNonUserCodeAttribute()] public override System.Data.DataTable Clone() { AssignmentDataTable cln = ((AssignmentDataTable)(base.Clone())); cln.InitVars(); return cln; } [System.Diagnostics.DebuggerNonUserCodeAttribute()] protected override System.Data.DataTable CreateInstance() { return new AssignmentDataTable(); } [System.Diagnostics.DebuggerNonUserCodeAttribute()] internal void InitVars() { this.columnPayload = base.Columns["Payload"]; } [System.Diagnostics.DebuggerNonUserCodeAttribute()] private void InitClass() { this.columnPayload = new System.Data.DataColumn("Payload", typeof(byte[]), null, System.Data.MappingType.Element); base.Columns.Add(this.columnPayload); } [System.Diagnostics.DebuggerNonUserCodeAttribute()] public AssignmentRow NewAssignmentRow() { return ((AssignmentRow)(this.NewRow())); } [System.Diagnostics.DebuggerNonUserCodeAttribute()] protected override System.Data.DataRow NewRowFromBuilder(System.Data.DataRowBuilder builder) { return new AssignmentRow(builder); } [System.Diagnostics.DebuggerNonUserCodeAttribute()] protected override System.Type GetRowType() { return typeof(AssignmentRow); } [System.Diagnostics.DebuggerNonUserCodeAttribute()] protected override void OnRowChanged(System.Data.DataRowChangeEventArgs e) { base.OnRowChanged(e); if ((this.AssignmentRowChanged != null)) { this.AssignmentRowChanged(this, new AssignmentRowChangeEvent(((AssignmentRow)(e.Row)), e.Action)); } } [System.Diagnostics.DebuggerNonUserCodeAttribute()] protected override void OnRowChanging(System.Data.DataRowChangeEventArgs e) { base.OnRowChanging(e); if ((this.AssignmentRowChanging != null)) { this.AssignmentRowChanging(this, new AssignmentRowChangeEvent(((AssignmentRow)(e.Row)), e.Action)); } } [System.Diagnostics.DebuggerNonUserCodeAttribute()] protected override void OnRowDeleted(System.Data.DataRowChangeEventArgs e) { base.OnRowDeleted(e); if ((this.AssignmentRowDeleted != null)) { this.AssignmentRowDeleted(this, new AssignmentRowChangeEvent(((AssignmentRow)(e.Row)), e.Action)); } } [System.Diagnostics.DebuggerNonUserCodeAttribute()] protected override void OnRowDeleting(System.Data.DataRowChangeEventArgs e) { base.OnRowDeleting(e); if ((this.AssignmentRowDeleting != null)) { this.AssignmentRowDeleting(this, new AssignmentRowChangeEvent(((AssignmentRow)(e.Row)), e.Action)); } } [System.Diagnostics.DebuggerNonUserCodeAttribute()] public void RemoveAssignmentRow(AssignmentRow row) { this.Rows.Remove(row); } [System.Diagnostics.DebuggerNonUserCodeAttribute()] public static System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(System.Xml.Schema.XmlSchemaSet xs) { System.Xml.Schema.XmlSchemaComplexType type = new System.Xml.Schema.XmlSchemaComplexType(); System.Xml.Schema.XmlSchemaSequence sequence = new System.Xml.Schema.XmlSchemaSequence(); Assignments ds = new Assignments(); xs.Add(ds.GetSchemaSerializable()); System.Xml.Schema.XmlSchemaAny any1 = new System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); System.Xml.Schema.XmlSchemaAny any2 = new System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); System.Xml.Schema.XmlSchemaAttribute attribute1 = new System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); System.Xml.Schema.XmlSchemaAttribute attribute2 = new System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "AssignmentDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; return type; } } [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] public partial class AssignmentRow : System.Data.DataRow { private AssignmentDataTable tableAssignment; [System.Diagnostics.DebuggerNonUserCodeAttribute()] internal AssignmentRow(System.Data.DataRowBuilder rb) : base(rb) { this.tableAssignment = ((AssignmentDataTable)(this.Table)); } [System.Diagnostics.DebuggerNonUserCodeAttribute()] public byte[] Payload { get { try { return ((byte[])(this[this.tableAssignment.PayloadColumn])); } catch (System.InvalidCastException e) { throw new System.Data.StrongTypingException("The value for column \'Payload\' in table \'Assignment\' is DBNull.", e); } } set { this[this.tableAssignment.PayloadColumn] = value; } } [System.Diagnostics.DebuggerNonUserCodeAttribute()] public bool IsPayloadNull() { return this.IsNull(this.tableAssignment.PayloadColumn); } [System.Diagnostics.DebuggerNonUserCodeAttribute()] public void SetPayloadNull() { this[this.tableAssignment.PayloadColumn] = System.Convert.DBNull; } } [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] public class AssignmentRowChangeEvent : System.EventArgs { private AssignmentRow eventRow; private System.Data.DataRowAction eventAction; [System.Diagnostics.DebuggerNonUserCodeAttribute()] public AssignmentRowChangeEvent(AssignmentRow row, System.Data.DataRowAction action) { this.eventRow = row; this.eventAction = action; } [System.Diagnostics.DebuggerNonUserCodeAttribute()] public AssignmentRow Row { get { return this.eventRow; } } [System.Diagnostics.DebuggerNonUserCodeAttribute()] public System.Data.DataRowAction Action { get { return this.eventAction; } } } } }Save the following file as test.xml:
<?xml version="1.0" ?> <Assignment xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <Assignment> <Payload>54686973206973206A7573742061207465737421</Payload> </Assignment> </Assignment>Save the following file as test.xsd(the project doesn't use it, just for your reference):
<?xml version="1.0" encoding="UTF-8"?> <xs:schema id="Assignment" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xs:element name="Assignments" msdata:IsDataSet="true" msdata:Locale=""> <xs:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element name="Assignment"> <xs:complexType> <xs:sequence> <xs:element name="Payload" type="xs:hexBinary" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> </xs:choice> </xs:complexType> </xs:element> </xs:schema>
"Do not let any unwholesome talk come out of your mouths,
but only what is helpful for building others up according to their needs,
that it may benefit those who listen."
- Ephesians 4:29-30 NIV
Dare to Question -- Care to Answer
Time is like water in a sponge, as long as you are willing you can always squeeze some.
--Lu Xun, Father of Modern Chinese Literature