![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Sep 2011
Posts: 4
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Feb 2011
Posts: 42
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Sep 2011
Posts: 4
Rep Power: 0
![]() |
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();
}
}
} |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Feb 2011
Posts: 42
Rep Power: 0
![]() |
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 ![]() |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Sep 2011
Posts: 4
Rep Power: 0
![]() |
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();
}
}
} |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
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 |