在 C# 中公开 DLL 的方法
当有人使用 Microsoft Visual 开发环境用 C# 创建 DLL 后,另一个程序员将如何获取该代码、创建一个包含 DLL 源代码的新项目并创建一个使用 DLL 的 API 的 GUI?
我已经完成了以下四个步骤:
1)在解决方案资源管理器中右键单击“引用”并选择“添加引用...”。
2) 选择“浏览”选项卡。
3) 导航到 DLL 并选择它。
4) 在代码顶部添加适当的“using”指令。
下一步是什么? 声明一个新对象后,如何查看要使用哪些方法?
After someone creates a DLL in C# using the Microsoft Visual development environment, how would another programmer take that code, make a new project that includes the DLL's source and make a GUI that uses the DLL'S API?
I have already done the following four steps:
1) In the Solution Explorer right-click "References" and select "Add Reference ...".
2) Select the "Browse" tab.
3) Navigate to the DLL and select it.
4) Add the appropriate "using" directive to the top of the code.
What is next? After I declare a new object, how do I see what methods to use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
查看菜单 -> 对象浏览器
您应该能够查看 DLL 中包含并公开公开的对象/方法等。
View Menu -> Object Browser
You should be able to look at the objects/methods and so on contained in the DLL and publicly exposed.
您应该能够像往常一样使用智能感知和对象资源管理器。 没有来源,这将是你最好的选择。
You should be able to use intellisense and the object explorer as always. Without the source that will be your best bet.
我脑子里没有任何代码,但是你研究过 Reflection 库吗?
你应该能够弄清楚并运行你需要的一切......
I don't have any code off the top of my head but have you investigated the Reflection library?
You should be able to figure out and run everything you need with that...
您可以通过 red-gate 的 .NET Reflector 工具加载 DLL,并查看所有 api,甚至它是如何实现的 http://www.red-gate.com/products/reflector/
you can load the DLL via the .NET Reflector tool from red-gate and see all of the api and even how it was implemented http://www.red-gate.com/products/reflector/
好吧...
假设您的库名为 MyLib.DLL
您会这样做:
;)
Well...
Suppose your library is called MyLib.DLL
You would do:
;)
您可以在名为“.NET Reflector 的第三方工具中打开任何 .NET DLL ”。 该工具将允许您查看所有类型/方法/属性,甚至反编译 DLL 中包含的代码。
.NET Reflector 类似于 Visual Studio 中的对象浏览器,但功能更强大。
如果您还没有尝试过 Reflector,我强烈推荐它(它真的很容易使用)!
You can open any .NET DLL in this 3rd party tool called ".NET Reflector". This tool will allow you to view all the types/methods/properties and even decompile the code contained in the DLL.
.NET Reflector is similar to the object browser in Visual Studio, but is way more powerful.
If you haven't tried Reflector yet, I highly recommend it (it's really easy to use)!