Reading in a type from an XML file

  • Thread starter Thread starter Earl
  • Start date Start date
E

Earl

How do I read in a type from XML? I can successfully write the value out to
the file as a type, but I cannot read it back in. Here is partial code for
the save portion:

Private NT As Type = GetType(NetworkType)
Private m_PubNetworkType As NetworkType

............
Dim dcPubNetworkType As DataColumn = dt.Columns.Add("PublisherNetworkType",
NT)
drNew("PublisherNetworkType") = m_PubNetworkType

Here is partial code for the retrieval portion. This would seem to cast the
input field to a type, but when I pull the file in, I get a NullReference
exception (despite the fact that the field IS populated in the XML file).

m_PubNetworkType =
CType(dsIn.Tables("ReplicationSettings").Rows(0)("PublisherNetworkType"),
NetworkType)

Here is the written schema:
<xs:element name="PublisherNetworkType"
msdata:DataType="System.Data.SqlServerCe.NetworkType" type="xs:string"
minOccurs="0" />

Here is the written XML:
<PublisherNetworkType>DefaultNetwork</PublisherNetworkType>
 
That is the general idea, unfortunately, NetworkType and SecurityType are
not System types and apparently cannot be assigned in that fashion. Thus my
question.
 
Earl,
That is the general idea, unfortunately, NetworkType and SecurityType are
not System types and apparently cannot be assigned in that fashion. Thus
my question.
In my ideas are it in your sample just column (item) names, therefore I
don't understand why you cannot get the type with the sample I gave you. It
can of course be nothing when there is no schema where it is set. (The last
not tested).

Cor
 
The "sample you gave me" is the standard MSDN sample, and only allows
standard System types and no others.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top