按代码将DLL添加到WPF应用程序 [英] Add DLL to WPF Application by code

查看:121
本文介绍了按代码将DLL添加到WPF应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个项目,还有一个UserControlLibrary。我已经创建了UserControlLibary.Now的DLL,我想通过代码将它添加到我的应用程序中。



我试过这个,但它不起作用。

Hi,
I have a project and also have a UserControlLibrary. I have created DLL of UserControlLibary.Now, I want to add it to my application by code.

I tried this, but it doesn't work.

Assembly a = Assembly.LoadFrom("user.dll");
Type myType = a.GetType();
UserControl user = (UserControl)a.CreateInstance(myType);
this.main_grid.Children.Add(user);





我该怎么办?



How can i do?

推荐答案

I建议您有一个lib目录或者您将库复制到的目录,然后添加对它的引用。
I suggest you have a "lib" directory or something where you copy your library to, and then add a reference to that.


这篇关于按代码将DLL添加到WPF应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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