Load a .DLL file and access methods from class within?

前端 未结 3 1006
深忆病人
深忆病人 2020-11-30 04:36

I\'m completely new to loading in libraries like this, but here\'s where I stand:

I have a homemade DLL file it\'s about as simple as it gets, the class itself and a

3条回答
  •  盖世英雄少女心
    2020-11-30 05:37

    This is how you can get the classes if you know the type.

    Assembly assembly = Assembly.LoadFrom("C:\\dll\\test.dll");
    
    // Load the object
    string fullTypeName = "MyNamespace.YourType";
    
    YourType myType = assembly.CreateInstance(fullTypeName);
    

    The full type name is important. Since you aren't adding the .dll you can't do a Using because it is not in your project.

    If you want all I would just Jon Skeet answer.

提交回复
热议问题