473,394 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Problems using GetType in deserialisation

Can anyone give me a pointer as where I'm going wrong?
I'm building a base class that persists to a database using serialization.

GetDoc() is a base class function that reads back XML to deserialize into a
new instance.
The derived class needs to convert the resultant object into an instance of
itself -
or at least it would do except I can't get GetType to return a reference to
the current running type to cast the object:

Public Function GetDoc(ByVal ID As Decimal)

Dim xs As XmlSerializer
Dim rdr As StringReader = Me.ReadDBString(ID)
Dim obj As Object

Try
xs = New XmlSerializer(Me.GetType)
obj = xs.Deserialize(rdr)

Dim MyType As Type = Me.GetType
Return DirectCast(obj, mytype) ' fails
miserable, compile error mytype not defined

Catch ex As Exception
ErrorLog.Add(ex)

Finally
xs = Nothing
rdr = Nothing

End Try

End Function

I know this should be possible, but I'm obviously missing a trick. Any
constructive suggestions would be welcome, and thanks in advance.

Will Lusted
Nov 12 '05 #1
0 1531

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Lina | last post by:
Hi, I am trying to create my own dataset and assign it to a datagrid. However i keep encountering the following error... An unhandled exception of type 'System.NullReferenceException'...
2
by: Will Lusted | last post by:
Can anyone give me a pointer as where I'm going wrong? I'm building a base class that persists to a database using serialization. GetDoc() is a base class function that reads back XML to...
3
by: Bill C. | last post by:
Hello, I know this has been discussed a lot already because I've been searching around for information the last few weeks. I'm trying to implement a DataGridComboBoxColumn class. I've found...
2
by: Huw | last post by:
I have written a small procedure that opens a dialog that I pass it. Sub MyOpen(txtForm as string) Dim frm As Object Dim frmType As Type frmType = Type.GetType(txtForm) frm =...
1
by: John Dann | last post by:
I need to read a binary file (whose structure I know - at least in generic terms) and just learning about how best to do it. Looking at deserialisation this seems to be one direct approach. But...
0
by: John Olbert | last post by:
I am trying to understand how legacy controls (for example, those created with Visual Studio C++ 6.0) work in Vs2005. I have run into some problems. The legacy control is MfcAxc1.ocx. After...
0
by: Richard Lewis | last post by:
I have a web service that is used from a Pocket PC device using .NET CF 1.1 The webservice creates an object structure and serialises the object structure to create the following SOAP response ...
0
by: mvisnich | last post by:
Hi, I am working in VS2005 (VB) environment and I have following problem: On one of my web pages I use Datagrid control which I dynamically load. I also use numerical paging with Datagrid....
2
by: shivendravikramsingh | last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if...
1
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hi misters, I have a solution with several projects. One project is a Windows Application using VB.NET. When I try design a UserControl (that Inherits from another UserControl) it
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.