# [.net] Call Methods and Access Resources in a DLL Linked at Runtime

This topic is 4157 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hiya, once again thanks for reading this. WARNING: NEWBIE ALERT...I'm brand new to C#, but fairly experienced with C++. I have a dll which I am linking to at runtime. I've managed to load the dll file but I can't figure out how to call methods in the dll from the main program or to access resources which are imbedded in the dll. Help! Code thus far is as follows: Assembly assembly = Assembly.LoadFile(Environment.CurrentDirectory + "\\" + library); foreach (Type type in assembly.GetTypes()) { if (!type.IsClass || type.IsNotPublic) continue; Type[] interfaces = type.GetInterfaces(); object obj = Activator.CreateInstance(type); ... } Remember, be kind to newbies...And, thanks for the help.

##### Share on other sites
The topic you want to read up on is called 'Reflection', in the namespace System.Reflection. As I remember the general sort of thing you want to do is
type.Invoke(obj, BindingFlags.Method, "MethodName", new object[]{params})

... but I haven't actually used this stuff for a few months and don't have the docs on this computer, so that's almost certainly wrong in detail.

Read the .Net Help/MSDN examples, as I recall they're actually quite good on this subject.

(Edit: it was definitely wrong in detail since I missed a bracket ;D)