使用DLL而不参考 [英] Use DLL without reference

查看:93
本文介绍了使用DLL而不参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的WPF应用程序中使用互操作DLL的功能,但不在我的项目中添加DLL作为参考。如何在运行时添加此DLL并调用DLL中的方法?



我尝试过:



如果我将DLL添加为参考并调用如下方法,DLL的函数就可以正常工作:

I need to use to interop features of a DLL in my WPF application, but without adding the DLL as a reference in my project. How would add this DLL at runtime and call a method in the DLL?

What I have tried:

The DLL's function works just fine if I add the DLL as a reference and call the method like this:

InteropAssembly.LabVIEWExports.WaveForm_Analysis(xyValues, out avgTorque, out bdcLocation, out bdcValue, out tdcLocation, out tdcValue, out startTorqueLocation, out startTorqueValue);

推荐答案

这是正确的方法:如果您的代码需要.NET程序集,那么添加引用是正确的方法。



你可以不用,但它更复杂,并且使你的代码更难阅读: C# - 从.NET DLL(类库)执行代码而不引用它? - 堆栈溢出 [ ^ ]
That's the right way to do it: if your code needs a .NET assembly, then adding a reference is the right way to do it.

You can do it without, but it's a lot more complex, and makes your code a lot harder to read: C# - Execute code from a .NET DLL (Class Library) without referencing it? - Stack Overflow[^]


c#在运行时加载dll - Google搜索 [ ^ ]


这篇关于使用DLL而不参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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