如何将项目子主窗体称为另一个项目 [英] how to call project sub main form another project

查看:91
本文介绍了如何将项目子主窗体称为另一个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有在VS 2010中开发的应用程序.
在那儿,我在VS 2010的一个解决方案下有两个项目.
我想从首先执行的主项目sub main()调用另一个项目子main.
该怎么做?
我是否必须为该子main()做一个对象?

I have application developed in VS 2010.
In that, I have two projects under one solution in VS 2010.
I want to call another projects sub main from main projects sub main() which executes first.
How to do that ?
whether I have to make an object for that sub main () ?

推荐答案

您不理解:"首先执行 ……不!

您不能运行两个进程并调用彼此的功能(我不认为严格来说不是调用远程过程调用).另外,在运行时,您应该说的是程序集,而不是项目.项目是一个编译时概念,可以是任何东西.

因此,您可以通过另一个程序集调用一个程序集的方法,但是只有一个程序集才能启动应用程序和过程.它称为输入程序集(通常是* .exe文件).所有其他程序集都应该是库(通常是* .dll,但可以是任何东西,甚至* .exe;唯一重要的事情是它不是作为进程启动的;它可以像进程一样启动,但在这种情况下,它可以是完全不同的过程).

因此,库程序集应将方法以及声明类型设为公开. (我将类型"使用复数形式,因为类和结构可以嵌套.)

在调用程序集项目时,在其引用"模式下,使用添加引用".由于两个程序集已经在同一个解决方案中,因此请选择项目".这样,您将获得从相同解决方案中选择的项目.它还将自动设置解决方案的项目依赖项.

—SA
You don''t understand something: "which executes first"… No!

You cannot run two processes and call each others function (I do not consider remote procedure calls which are strictly speaking not calls). Also, when it comes to run time, you should speak of assemblies, not projects. Project is a compile-time notion and can be anything.

So, you can call a method of one assembly by other assembly, but only one of the assembly should start the application and the process. It is called entry assembly (usually *.exe files). All other assemblies should be libraries (usually *.dll, but can be anything, even *.exe; the only important things is it is not started as a process; it can be started like a process, but in this case it would be completely different process).

So, the library assembly should make the method to be called public, as well as the declaring types. (I use plural for "types" because classes and structures can be nested.)

In calling assembly project, on its "References" mode, use "Add references". As both assemblies are already in the same solution, prefer "Project". In this way, you will be presented a choice of projects from the same solutions. It will also setup solution''s project dependency automatically.

—SA


这篇关于如何将项目子主窗体称为另一个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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