首页 /
正文
可以通过该方法来实现程序插件化。
假设A,B两个类,A类为宿主,B类为插件需要加载到A类中:
class Program
{
public interface IHellow
{
void Hellow();
}
static void Main(string[] args)
{
Assembly ass = Assembly.LoadFrom("D:/xx.dll");
var wormMain = ass.GetTypes().FirstOrDefault(m => m.GetInterface(typeof(IHellow).Name) != null);
var tmpObj = (IHellow)Activator.CreateInstance(wormMain);
tmpObj.Hellow();
Console.Read();
}
}
namespace ClassLibrary1
{
public class WormMain : IHellow
{
public void Hellow()
{
Console.WriteLine("Test Ok");
}
}
}
需要引用一下A类的项目文件,以得到接口。
如果是连同依赖项一起被载入,应该调用Assembly.LoadFrom
A类输出结果:
"Test Ok"
版权属于: 顾锦歌——发现生活的美!
本文链接: https://main.huat.fun/index.php/archives/23/
本文最后更新于2022年02月28日 ,已超过1059天没有更新,若内容或图片失效,请留言反馈。
本文允许转载,但请在转载时请以超链接或其它形式标明文章出处
Your go-to source for leads. We can provide business to business and business to consumer leads, custom-tailored to your needs. CustomDatabases.org
Hi, It is with sad regret to inform you TopDataList.com is shutting down. We are ceasing operations on TopDataList.com and have made our leads available at a $149 once off fee. Visit us on TopDataList.com Regards, Otilia
Hello, from CustomData.click we are a provider of unique databases that could help your business. Please visit us at CustomData.click to see if we can help you. Regards, Ervin
Hello. It is with sad regret to inform you TopDataList.com is shutting down. We have made all our databases available for you for a once off fee. Visit us on TopDataList.com
ZippyLeads.org is running an easter special till the 18th of April. Get all the leads you need for your company with our easter special.
Hello. My name is Johan Fourie and I am looking to sell DataList.biz. We are a data company that has been in the industry for 12 years. We do around $170k/year in revenue. 1) I am looking to sell 50% of the business for $5k. 2) It would be helpful if you are knowledgeable about the Data Business. 3) I am looking for someone that is willing to take over administration, support, client relations. 4) I will continue to do the marketing for new products. 5) You will accept all future income and pay me from it. Please contact me on WhatsApp +27 72 280 1952 or my personal email: johanfourieinc@gmail.com if you are interested in this and we can have a call. Regards, Johan Fourie
Hi, I am interested in some of your products. Please give me a call on +1 304-873-4360
欢迎加入 Typecho 大家族