1

I need to create an object of a specific type.

The only clue i have on this type is a string (coming from a text file) and the assembly where i can find this object.

All the constructors of all the objects in this assembly have the same constructor signature, let's say :

public MyObject(object o)
{}

How can i pass this parameter to the constructor using Activator.CreateInstance (string assemblyName, string, className) ?

G.Dealmeida
  • 325
  • 3
  • 14
  • This post give you the answer: https://stackoverflow.com/questions/2451336/how-to-pass-parameters-to-activator-createinstancet – Roberto Conte Rosito Nov 09 '17 at 15:53
  • Actually no, i have seen it and read it before posting my question...the difference is, in my case, i dont know the target type specificly, i only have a string to "reflect" – G.Dealmeida Nov 10 '17 at 08:30
  • ... on this site, people consider "duplicate question" far too easily.... i copy paste the title of the so-called "duplicated question".... on purpose.... hoping that people will see how it is diferent. After few hours i have found a way to solve my problem.. a way which is not explain in the so called "duplicated question"... and i can't post it here and help the community with it. Please consider unmarked it so i can answer to my post pls – G.Dealmeida Nov 10 '17 at 10:32
  • @G.Dealmeida: Could you post your answer here in the comments. I seemed to face a similar situation here. Thanks! – re3el Dec 31 '18 at 21:51

0 Answers0