Get object from string

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

Guest

Hi,

I have a type name in XML file as a string and I need to make an instance
form it.
I tried:
Assembly asm = Assembly.Load(".....smo.dll");
object obj = asm.Create("SqlDataType.NVarChar");


The variable obj is always null.

What am I missing?

Thanks,

Lubomir
 
Hi,

How is your type described?
Does it has the full namespace paath?
 
Hi,


Lubomir said:
SQLDataType is an enumeration defined in microsoft.sqlserver.smo.dll


I have never tried that. Basically you want to create a variable to be a
member of an enumerator.
If that is the case I think you should use Enum.Parse( ".....SqlDataType",
"NVarChar");
 
Hi,

Yes, that works.

Thanks,

Lubomir


Ignacio Machin ( .NET/ C# MVP ) said:
Hi,





I have never tried that. Basically you want to create a variable to be a
member of an enumerator.
If that is the case I think you should use Enum.Parse( ".....SqlDataType",
"NVarChar");
 
Back
Top