no vailid "Main" entry point

This is a discussion on no vailid "Main" entry point within the C# Programming forums, part of the General Programming Boards category; Code: using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Text; using System.String; namespace JWGenetics { // instance Class public ...

  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    4

    no vailid "Main" entry point

    Code:
    using System;
    using System.IO;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.String;
    
    namespace JWGenetics
    {
        // instance Class
        public class Prog
        {
    
     //  public static void Main(string[] args)
            static void Main()
    
    
    
           {
               Genetics jw = new Genetics();
                jw.prog();
            } // end main
        
        }     // end class prog
    
          public  class Genetics
            {
    
                //create list for sire data
                public List<int> siregtype = new List<int>();
                //create list for dam data
                public List<int> damgtype = new List<int>();
                public const int rows = 128;
                public const int columns = 7;
                // create lists for dictionaries
                public List<int> colorslist = new List<int>();
                public List<int> gtypelist = new List<int>();
    
    
                // create sire & dam data 2D arrays
                public int[,] siredata = new int[rows, columns];
                public int[,] damdata = new int[rows, columns];
                //create offspring 1D array
                public int[] offspring = new int[14];
                // create sire && dam 1D arrays
                public int[] sire = new int[14];
                public int[] dam = new int[14];
                // create child 4D array
                public int[, , ,] child = new int[color_counter, 4];
    
                public Dictionary<string, int> colors = new Dictionary<string, int>();
                public string color; //name
                Dictionary<string, string> geneo = new Dictionary<string, string>();
                public string gtype; //geneotype 
    
    
                // gene groups
                public int Broken, Agouti, Brown, Colour, Dilute, Ext, Vienna;
    
                // Vienna types flags
                bool vienna = false; bool vm = false; bool vc = false;
                //color flags
                bool dilute = false; bool charlie = false; bool broken = false; bool rew = false;
    
                // data holders
                public int sen1, sen2, sa1, sa2, sb1, sb2, sc1, sc2, sd1, sd2, se1, se2, sv1, sv2;
                public int den1, den2, da1, da2, db1, db2, dc1, dc2, dd1, dd2, de1, de2, dv1, dv2;
                public char colorpct;
    
                // declare counters //
                public int sirecounter = 0;
                public int damcounter = 0;
                public int offspringcounter = 0;
                public int totalcount = 0;
                public int color_count = 0;
                public static bool e_trap;
    
    
        
              // main function
    
    
                // start program run          
                public void program()
                {
                    //housekeeping
                    // array setup variables for parseing combinations into the correct fields
                    Broken = (rows / 2);
                    Agouti = (Broken / 2);
                    Brown = (Agouti / 2);
                    Colour = (Brown / 2);
                    Dilute = (Colour / 2);
                    Ext = (Dilute / 2);
                    Vienna = (Ext / 2);
    
                    setup_sire();
                    setup_dam();
                    child_setup();
                    //  child_calc();  // determine % of each pheneotype && output to screen
    
    
                    return;
                }
    I'm getting this message:
    Error 1 Program 'C:\Documents and Settings\XXXX\My Documents\Visual Studio 2010\Projects\LapinGenetics1\ConsoleApplication1\o bj\x86\Release\RabbitGenetics.exe' does not contain a static 'Main' method suitable for an entry point

    I've checked the properties settings and they seem fine. What should be the properties settings?

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,439
    Make main() public, please.

    Don't know why you feel the need to comment the main method supplied to you. But in any case, making your replacement method public is all you need.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    But in any case, making your replacement method public is all you need.
    I doubt that. The CLR doesn't give a hoot about the access modifier applied to Main(). More likely is that the build settings for the project got mucked up. Perhaps the build action for that file isn't set to "Compile".
    My best code is written with the delete key.

  4. #4
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,650
    You're also calling
    Code:
    jw.prog()
    , but there's no prog() method in the Genetics class.

  5. #5
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,439
    Yup. Sorry about that. Confessedly I lost track of the main entry rules, being that this is automatically supplied to me. One of the "perks" of making it simple for us. Neither, to be true, I payed enough attention to the code.

    So... let's do this properly:

    The class where main() resides is not the default Program class. So if you wish that main function to be your entry point, you need to alter the project properties. Under the tab Application, you'll find a Startup object listbox. Set it to point to JWGenetics.Prog. That should fix this particular error. Note that I'm not looking at any other part of your code.
    Last edited by Mario F.; 09-02-2011 at 12:13 PM.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  6. #6
    Registered User
    Join Date
    Aug 2011
    Posts
    4
    Thanks for the info.
    I've tried to change the startup object but I can't change it. It's stuck on not set and no other options are given.

  7. #7
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Why don't you just make a new project and paste your code into it? Make sure you paste it all - as your first example is actually missing a few closing braces.


    Quzah.
    Hope is the first step on the road to disappointment.

  8. #8
    Registered User
    Join Date
    Sep 2011
    Posts
    71
    "I've tried to change the startup object but I can't change it. It's stuck on not set and no other options are given. "

    Make sure all the projects within the solution have a Main entry point.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 12-02-2007, 04:55 AM
  2. Replies: 7
    Last Post: 07-03-2007, 01:49 PM
  3. " void main() is evil. Use int main(). "
    By Brw_Abhi in forum C++ Programming
    Replies: 7
    Last Post: 06-06-2007, 12:16 PM
  4. "itoa"-"_itoa" , "inp"-"_inp", Why some functions have "
    By L.O.K. in forum Windows Programming
    Replies: 5
    Last Post: 12-08-2002, 07:25 AM
  5. "CWnd"-"HWnd","CBitmap"-"HBitmap"...., What is mean by "
    By L.O.K. in forum Windows Programming
    Replies: 2
    Last Post: 12-04-2002, 06:59 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21