I am making a scripting language but I have a serious problem.
I need to make it so you can call .NET DLLs in the language but I have found no way to do this in C#.
Does any one know how can I load and call a .NET dll programmatically? (I can not just Add reference so don't say that)
Here's how I did it:
where
assemblyName
andtypeName
are strings, for example:then you can call methods on your obj:
Of course, what methods you can call is defined by your interface
IYourType
...It sounds like you need to use one of the overloads of Assembly.Load (Assembly.Load at MSDN). Once you have dynamically loaded your assembly, you can use System.Reflection, dynamic objects, and/or interfaces/base classes to access types within it.
You can use Assembly.LoadFrom, from there use standard reflection to get at types and methods (i assume you already do this in your scripting). The example on the MSDN page (linked) shows this: