Catching (and fixing) type related errors

David Rutten

New member
Joined
Dec 13, 2005
Messages
3
Location
Turku, Finland
Programming Experience
5-10
Hello,

this is a complicated issue, so hopefully I can get my point across...:

My application allows for runtime compiled VB.NET code. Users enter a String representing some code, I compile it into a memory-assembly and use InvokeMember() to call methods on the classes inside this assembly.

A number of variables are made available by default. For the sake of argument, let's say that inside the custom compiled class, there is a variable called R:

Public R As Object = Nothing

Then, the function which contains the user code will assign values to R, and I read those afterwards, interpreting what happened. Say, people write:

R = 4

-or-

R = New Circle(New Point(0.0,2.0,-3.5), 5.0))

In both cases, everything is on the up-and-up. The problem arises when people assign a value to R, then expect to call methods on that value, say:

R = New List(Of Circle)
For i = 1 To 10
R.Add(New Circle(New Point(0,0,0.5*i), i))
Next


This code cannot be compiled because System.Object does not have an .Add() method. Can anybody think of any kind of solution for this?

Much obliged,
David

--
David Rutten
Robert McNeel & Associates
 
"option strict" disallow late binding, how you are compiling is not known but you should be able to set a warning level of some sort to allow late binding, the other options are only explicit casting or reflection invoke.
 
Back
Top