Using System.Reflection

丶灬走出姿态 提交于 2019-12-25 03:47:07

问题


Im loading an Exe into my application using Assembly.LoadFile(). From that is it possible to get the Method of a particular class from that EXE. Thanks in advance .


回答1:


Try:

    var assembly = Assembly.LoadFile("C:\path-to-some-app.exe");
    var desiredType = assembly.GetType("SomeNamespace.SomeClass");
    var methodInfo = desiredType.GetMethod("MethodName");



回答2:


A number of things you can do with Reflection (Including constructors, method invocation etc.) Tutorial at : http://www.csharp-examples.net/reflection-examples/



来源:https://stackoverflow.com/questions/4274227/using-system-reflection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!