Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 10th, 2011, 5:33 PM   #1
zulu
Newbie
 
Join Date: Sep 2011
Posts: 4
Rep Power: 0 zulu is on a distinguished road
Help with C# Library Project and startup object?

Hi guys,

I am new to C# (I usually write VB.NET) and even then I am just a weekend programmer for small projects. Recently I created a C# Library Project, and tried to run it in VS but got a error pop up that stated no start up object found. I then tried to place a static Main() method in the class file and still no go. I also checked the debug tab in properties looking for a start up object but that's also empty. Is there something else I can try??

Thanks.
zulu is offline   Reply With Quote
Old Sep 10th, 2011, 5:50 PM   #2
Momerath
Programmer
 
Join Date: Feb 2011
Posts: 44
Rep Power: 0 Momerath is on a distinguished road
Re: Help with C# Library Project and startup object?

Go to menu Project and click the last item in the menu (should by "your project name Properties".
Go to the Application tab.
You should see a dropdown list with the lable "Startup object". Select the class that contains your Main() method.

Remember your Main method needs to be static.
Momerath is offline   Reply With Quote
Old Sep 10th, 2011, 6:06 PM   #3
zulu
Newbie
 
Join Date: Sep 2011
Posts: 4
Rep Power: 0 zulu is on a distinguished road
Re: Help with C# Library Project and startup object?

That "dropdown list with the lable "Startup object"" is still empty, says (Not Set)

namespace Algebra1
{
    public class Class1_Main
    {

        public static void Main()
        {
            // Create a new instance of the form.
            Form frm1 = new Form1();
            // Display the form as a modal dialog box.
            frm1.ShowDialog();
        }

    }
}
Attached Images
File Type: jpg notset.JPG (57.2 KB, 4 views)
zulu is offline   Reply With Quote
Old Sep 11th, 2011, 12:57 PM   #4
Momerath
Programmer
 
Join Date: Feb 2011
Posts: 44
Rep Power: 0 Momerath is on a distinguished road
Re: Help with C# Library Project and startup object?

I should have paid more attention to your original post, you actually did mean what you said

If you take a look at your picture again, look at the "Output Type" dropdown and you'll see "Class Library". That means this produces a DLL. You can't run a DLL.

There are a few things you can do:
1) Change the Output Type to either "Console Application" or "Windows Application". This will allow you to set the Startup Object.
2) Create another project within this project (right click the project name in the Solution Explorer). Make sure this new project references the DLL. Write your start-up and test code there.
3) Create an entirely new project that references the original projects DLL. This is like the 2nd option, except the two projects aren't 'linked' in Visual Studio. This is what I tend to do (I keep two copies of VS open). For 'official' testing, I use option 2
Momerath is offline   Reply With Quote
Old Sep 11th, 2011, 5:30 PM   #5
zulu
Newbie
 
Join Date: Sep 2011
Posts: 4
Rep Power: 0 zulu is on a distinguished road
Re: Help with C# Library Project and startup object?

Yeah, but I can see how I could have confused people too. Thanks for the tips you posted, its helped me a lot and I learned something new as well.

So in case anyone else has a similar issue and reads this here what I did (based on you advice), the second project added was a console app, then I used that Main as the entry point; I then changed this to a Windows Application so the cmd would not open.

I guess someone might think why did I just not create a single Windows app.....well this program needs to be a .dll file and not .exe since its being used in another programs API that can only call a .dll

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Algebra1; // <- from the first project Algebra1.dll
                //      referenced in the second project.

namespace StartPoint
{
    class Program
    {
        static void Main(string[] args)
        {

            Algebra1.Class1.mForm();
            
        }
    }
}
Attached Images
File Type: jpg 2ndProj.JPG (79.4 KB, 3 views)
File Type: jpg addProjectIntoAnother.JPG (29.0 KB, 2 views)
zulu is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Special browser in Java (Project) stalefish Java 3 Feb 9th, 2008 4:22 PM
How to set startup form? Robocop C# 7 Sep 1st, 2007 6:12 AM
Project Idea: Startup Manager AntiNinja Project Ideas 6 Jul 31st, 2006 3:52 PM
Looking for Programmers for Special Project ct_prog Coder's Corner Lounge 6 Jun 24th, 2005 8:35 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:51 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC