Type.GetType("System.Drawing.Point")) error...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm building a dataset that writes out a Point type value.
Here's the code that I've got:

1 Dim dsContent As DataSet = New DataSet("content")
2 Dim dtAsset As DataTable = New DataTable("asset")
3 Dim dcPk(0) As DataColumn
4 dcPk(0) = _
5 dtAsset.Columns.Add("fullName", Type.GetType("System.String"))
6 dtAsset.Columns.Add("videoLocation",
Type.GetType("System.Drawing.Point"))
7 dtAsset.Columns.Add("videoSize", Type.GetType("System.Drawing.Size"))
8 dtAsset.PrimaryKey = dcPk 'define primary key for this table
9 dsContent.Tables.Add(dtAsset)

The code compiles just fine but always blows up on line #6 stating:

An unhandled exception of type 'System.ArgumentNullException'
occurred in system.data.dll
Additional information: 'dataType' argument cannot be null.

How any idea what the problem is here and how to correct it?
 
By default Type.GetType searched for requested type in mscorlib and in
executing assembly. You have to provide assembly qualified type name,
like

Type.GetType("System.Drawing.Point, System.Drawing, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
 
How any idea what the problem is here and how to correct it?

The problem is that you have to specify the fully qualified type name
which includes the assembly name.

If you have a reference to System.Drawing.dll use the GetType operator
instead.

dtAsset.Columns.Add("videoSize", GetType(System.Drawing.Size))


Mattias
 
Thanks that seems to work for me... where can I find the fully qualified type
name for other types... (like Size, etc.)...
 
if you have references to assemblies where these types are located, it
will be easier to use typeof() operator
 
Nope, I don't have refs to the assemblies where these types are located...

Is there an easy way to obtain/determine the fully qualified type name for a
specified type (i.e. Point, Size, etc.)

Thanks for your help!
 
Back
Top