jeudi 4 février 2016

Using a string name for an object and an assembly

I'm not great with reflection and I hope I chose the right category. I have an interesting problem. I have written a report using devexpress reports. This involves a line of code like this: lxListData = New System.Collections.Generic.List(Of DLL.Report.ListData)

ListData is report in an assembly external to the one where the above line is executed. The above line works fine and allows me to run the report.

What I've done is put all the information for this report into a table as strings, That includes the type:" DLL.Report.ListData"

What I need is to change this string name into the type used in the line of code above. I have tried:

Dim type1 As Type = System.Reflection.Assembly.LoadWithPartialName("DLL.Report").GetType("DLL.Report.ListData")

and then changing the line above to: lxListData = New System.Collections.Generic.List(Of type1)

I've tried a few other techniques that are similar. In all cases the "type1" variable is not seen as a type even though it looks like it is in the watch window.

Any advice would be appreciated.

Thanks, Neil





Aucun commentaire:

Enregistrer un commentaire