试图使用一个类作为dll引用. [英] Trying to use a class as dll reference.

查看:62
本文介绍了试图使用一个类作为dll引用.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.我得到了一段必须用作类的代码.每次将其添加到项目中,都可以从表单的代码中进行访问.
它用于与工业无线电的以太网通信.
所以现在这只是一个叫做MK的类
问题:
是否可以将一个类编译成一个DLL,然后可以将其仅引用到每个应用程序?如果是这样,我该怎么办?我可以创建一个DLL应用程序并进行编译,但是当我引用它时,我将无法访问这些函数.


Thanx

Hi all. I got a piece of code that I have to use as a class. It gets added to the project every time, the accessed from the code of the forms.
It is for ethernet communication to an industrial radio.
So right now it''s a just a class called MK
Question:
Is it possible to compile a class into a DLL which then can be just referenced to each application? If so how do I go about it? I can create a DLL application and compile it but then when I reference it I can''t access the functions.


Thanx

推荐答案

是的.如果您的项目是一个类库,则在构建类时会将这些类编译为DLL.我确定您已经熟悉如何将DLL引用到其他项目.我认为唯一缺少的是,您没有在代码中放入您引用的DLL的导入名称空间.我认为这就是为什么您无法访问代码中的类的原因.希望对您有所帮助.
Yes its possible. If your project is a class library, the classes gets compiled to a DLL when you build it. Im sure you''re already familiar with how to reference the DLL to the other projects. The only lacking thing I think, is that you haven''t put in the code the import namespace of the DLL you referenced. This is why, I think, you are not able to access the classes on the code. Hope this helps.


确保将要访问的功能声明为公共而非私有".
Make sure the functions that you want accesible are declared as Public not Private.


这篇关于试图使用一个类作为dll引用.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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