如何在.net C#中访问另一个程序集的成员 [英] How to access members of another assembly in .net C#

查看:59
本文介绍了如何在.net C#中访问另一个程序集的成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我想实现访问.net C#中另一个程序集的成员。据我所知,其中一种方法是通过反思。你能否列出或分享其他方法来实现这个目标?



谢谢。

快乐编码!!。

Hi All,

I would like to implement to access members of another assembly in .net C#. As per my knowledge one of the ways is through Reflection. Could you please list out or share the alternative ways to achieve this?

Thank you.
Happy coding!!.

推荐答案

最简单的方法是在项目中添加对程序集的引用,然后使用语句添加相应的,并访问汇编类成员直接与.NET程序集及其包含的类一样。
Easiest way is to add a reference to the assembly in your project, then add the appropriate using statement, and access the assembly class members directly in the same way you do .NET assemblies and the classes they contain.


如果您有权访问dll,为什么不将它添加为参考?

如果没有,你可以试试反射。
If you have access to the dll, why don't you add it as reference?
If not, you could try reflection.


嗨。使用此类:

Hi. Use this class:
using System.Runtime.CompilerServices




[assembly: InternalsVisibleTo]


这篇关于如何在.net C#中访问另一个程序集的成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆