跨项目打开表格 [英] Opening Forms Across Projects

查看:60
本文介绍了跨项目打开表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,



我正在写一个Windows表单应用程序,我在解决方案中有两个项目。我添加了一个项目引用来引用这两个项目。我正在尝试在另一个项目上打开一个表单,但是当我尝试使用它时,我得到'对非共享成员的引用需要一个对象引用。'错误



Launchform.show()



我已经添加了Imports Project2系列,这使我能够访问这些课程,但他们不会给我访问权限到我可以使用Form.Show(),Form.Close,Form.Focus等的表格。



我有什么方法可以分享表格项目?



感谢您的帮助:),

Chris

Hey,

I'm writing a Windows Form Application and I have two projects in the solution. I've added a project reference to reference the two projects to each other. I'm trying to open a form on the other project, but I get the 'Reference to a non-shared member requires an object reference.' error when I try to use this

Launchform.show()

I've already added the Imports Project2 line which gives me access to the classes, but they won't give me access to the forms where I can use Form.Show(), Form.Close, Form.Focus, etc.

Is there any way I can share the forms across the projects?

Thanks for any help :),
Chris

推荐答案

这个问题与项目无关。您应该了解的第一件事是项目在运行时不存在。该项目是工件,它只是用于构建程序集的数据。在运行期间只有程序集是玩家。



当你遇到最简单的问题时,你没有接近运行时,甚至没有接近。您的 Launchform.Show()无法编译,因为从错误消息判断, Launchform 是一种类型,希望如此派生自 System.Windows.Forms.Form 显示是其实例方法。而实例方法需要引用某个实例,而不仅仅是类型。例如,这样的事情可以起作用:

This problem has nothing to do with "projects". First thing you should understand is that the "project" does not exist during run-time. The project is the artifact which is nothing but the data used to build an assembly. Only assemblies are the players during runtime.

And you did not approach runtime, not even close, as you faced with the simplest problem. Your Launchform.Show() could not compile, because, judging by the error message, Launchform is a type, hopefully derived from System.Windows.Forms.Form and Show is its instance method. And the instance method needs a reference to some instance, not just type. For example, something like this could work:
Dim form As Form = New Launchform()
' ...
form.Show()

同样,这一切都与你不同项目和多个程序集中的事实无关你的申请。使用多个程序集对于.NET来说是很自然的,也是它的基础之一。



你真正需要的是学习编程的基础知识,特别是OOP 。您需要了解类型及其实例(对象),托管引用,值与引用类型,程序集和模块,项目基础及其构建等等。



-SA

Again, it all has nothing to do with the fact you have to different project and more than one assembly in your application. Using multiple assemblies is very natural to .NET and is one of its bases.

What you really need is learning of the very basics of programming and, in particular, OOP. You need to understand type and their instance (object), managed references, value vs reference types, assemblies and modules, basics of projects and their builds, and so on.

—SA


这篇关于跨项目打开表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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