你好, 我有两个项目 - 一个是exe&另一个是dll。我将一个dll项目的引用添加到exe,以便它可以访问dll项目的类型。现在在我的dll项目中,我的代码需要引用exe项目;这是不可能的,因为它会导致循环依赖。因此,我正在做的就是我将exe'的类型称为例如exe项目的MDIForm到数据类型为Object 的dll项目。现在我可以愉快地访问dll项目中所有MDIForm的成员。 我的问题:
Hi there, I''ve two projects - one is an exe & the other is a dll. I add a reference of the dll project to the exe so that it can access dll project''s types. Now in my dll project I''ve code which requires reference to the exe project; this is not possible as it would result in circular dependency. Hence all I''m doing is I''m passing exe''s type say for example the MDIForm of the exe project to the dll project with datatype being Object. Now I can happily access all the MDIForm''s members in the dll project. My question:
谢谢, Aads
Thanks, Aads
推荐答案有一种方法可以对您作为对象传递的MDI表单进行类型化。 您只需提及具有Form类型的对象。因此intellisense将显示MDI表单对象的成员。 例如: C#: string formName =((Form )mdiFormObj).Name; There is a way to typecase your MDI form that you have passed as object. You just mention the object with the type of Form. So intellisense will show the members of the MDI form object. Eg: C#: string formName=((Form)mdiFormObj).Name;
感谢您的快速回复。 如果我将其类型化为Form,它只会显示标准表单成员不是我写的那个。例如:我可能已经用名称AddTwoNumbers编写了一个公共函数,它不会出现在intellisense中,因为它不是标准表单的成员,而是我的类的成员。我希望这个成员显示在intellisense中。实际上它可以是任何用户定义的类。 希望现在很清楚。 谢谢, Aads Thanks for your quick reply. If I typecast it to Form, It would only show the standard form members not the one which I have written. For example: I might have written a public function by name AddTwoNumbers, which would not appear in the intellisense as it is not a member of a standard form but the member of my class. I want this member to be displayed in the intellisense. In fact it could be any user defined class for that matter. Hope now its clear. Thanks, Aads
也许您应该考虑将所有自定义函数声明为接口(或其他东西)并将其保存在DLL中。 所以你可以以这种方式引用函数? Perhaps you should consider making all of your custom functions declared as an interface(or something) and keep that in the DLL. So you can reference the functions that way?
更多推荐
对象数据类型是对的吗?
发布评论