6 Replies - 830 Views - Last Post: 25 December 2009 - 09:56 AM Rate Topic: -----

#1 benlee105  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 25-December 09

Referencing Console App and Windows Form - Possible?

Posted 25 December 2009 - 05:12 AM

Hi,

My current situation now, is that I have two Projects under one Solution. E.g.

Solution 'Project' (2 Projects)
|
+- Project 1 (Windows Form)
|
+- Project 2 (Console App)


Project 1 is of course, the main GUI.

I would like to know, what criteria must I satisfy before I can insert the following code in a button in Project 1

Project2 p2 = new Project2();
p2.ShowDialog();
this.Hide();



Is it even possible?

What I've done: I have made a reference to Project 2 in Project 1.


Thanks,
Ben

Is This A Good Question/Topic? 0
  • +

Replies To: Referencing Console App and Windows Form - Possible?

#2 FlashM  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 382
  • View blog
  • Posts: 1,195
  • Joined: 03-December 09

Re: Referencing Console App and Windows Form - Possible?

Posted 25 December 2009 - 05:17 AM

Are you receiving any errors or you don't even see the Project 2 in your Project 1 class? Can you post some code of Project 2 to see the implementation.
Was This Post Helpful? 0
  • +
  • -

#3 benlee105  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 25-December 09

Re: Referencing Console App and Windows Form - Possible?

Posted 25 December 2009 - 06:33 AM

View PostFlashM, on 25 Dec, 2009 - 04:17 AM, said:

Are you receiving any errors or you don't even see the Project 2 in your Project 1 class? Can you post some code of Project 2 to see the implementation.


I am not receiving any errors, I am just unable to.. Call Project 2 at all in Project 1.

I have attached code from Project 2 for your viewing!


Thanks,
Ben

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#4 Core  Icon User is offline

  • using System.Linq;
  • member icon

Reputation: 774
  • View blog
  • Posts: 5,097
  • Joined: 08-December 08

Re: Referencing Console App and Windows Form - Possible?

Posted 25 December 2009 - 06:50 AM

Well, if you correctly referenced the project and you added a correct namespace declaration in the first project, all you have to do is add the public part to the Program class in the second project, so that it can be accessed externally.
Was This Post Helpful? 1
  • +
  • -

#5 benlee105  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 25-December 09

Re: Referencing Console App and Windows Form - Possible?

Posted 25 December 2009 - 07:23 AM

Thanks Core!
Was This Post Helpful? 0
  • +
  • -

#6 benlee105  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 25-December 09

Re: Referencing Console App and Windows Form - Possible?

Posted 25 December 2009 - 09:50 AM

Another problem I'm facing -

I am able to reference Project2.Program now, but I am unable to.. "Start" Project2.

Is there any quick way to.. Start the Console program?


One alternative I found was to import the dll Kernel32.dll, but that's a very roundabout way.
Was This Post Helpful? 0
  • +
  • -

#7 FlashM  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 382
  • View blog
  • Posts: 1,195
  • Joined: 03-December 09

Re: Referencing Console App and Windows Form - Possible?

Posted 25 December 2009 - 09:56 AM

This really depends on what you are trying to do. If you successfully referenced your Poject2 and are able to access its members (methods, properties etc...), then just call whatever method you want to execute it.

The second possibility - although this is just my guess on what you are trying to do - is that you want to run your Console app from Project1 just like you would launch it from Command Prompt. To do this, you can use the following:

System.Diagnostics.Process.Start(whatever parameters go here);

Check out MSDN help form Process class, because it has really a lot of things that can be set.

If you'll still have problems, contact forum members for help :-)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1