user1678541
user1678541

Reputation:

Combining two WinForms projects

I have to projects in my solution: StoreHelper and DefaultsSwitcher. Both of them have to create a Windows Executable (their output is application).

Now we are located in StoreHelper. This is my code:

At the top of the file:

using DefaultsSwitcher;

And in the file:

private void defaultsSwitcherToolStripMenuItem_Click( object sender, EventArgs e ) {
    var defaultsSwitcher = new DefaultsSwitcher.dialog();
    defaultsSwitcher.ShowDialog();
}

The code editor does not show any error by underlining, but when I try to build, the compiler say the following error:

Error   1   The type or namespace name 'dialog' does not exist in the namespace 'DefaultsSwitcher' (are you missing an assembly reference?) E:\Apps\StoreHelper\StoreHelper\mainWindow.cs   84  25  StoreHelper

Which is the problem? P.S. I want these two projects to pe .exe files after building.

The code in DefaultsSwitcher:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using StoreHelperLib.Options;

namespace DefaultsSwitcher {
    public class dialog : Form {
        public dialog() {
            var options = new iniHelper();
            if (!File.Exists( "settings.ini" )) {
                StreamWriter settings = new StreamWriter( "settings.ini" );
                settings.Close();
            }

            options.Load( "settings.ini" );
            options.AddSection( "Application" );
            options.SetKeyValue( "Application", "firstRun", "true" );
            options.SetKeyValue( "Application", "startGuide", "false" );

            options.Save( "settings.ini" );
            InitializeComponent();
        }
    }
}

Upvotes: 0

Views: 1585

Answers (3)

user1678541
user1678541

Reputation:

I found a solution for my problem to keep both projects output to EXE. I have just to use:

public partial class dialog

Upvotes: 0

Franck Charlier
Franck Charlier

Reputation: 439

I think that you have miss to include the child Project to his parent. To do this : Right clic on Reference folder in StoreHelper project and clic on Add Reference. Finally choose DefaultsSwitcher project.

Now the DefaultsSwitcher namespace must be accesible from the StoreHelper project

Upvotes: 1

Steven Hunt
Steven Hunt

Reputation: 2321

Is there any communication between the apps, or are you just trying to start the one app from the other app? If the latter, use System.Diagnostics.Process and have Windows run the other EXE file seperately.

http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx

This also means that you can have both apps be able to start the other because there would not be a circular dependency.

Upvotes: 1

Related Questions