CRM 2011 – Sample Visual Studio Projects contain more than one entry point

I had a noddy error today in visual studio but they are always frustrating when you are trying to translate the error into what you have to do to fix the darn thing.  They always offer you hints in the right direction but never tell you definitely where to go.

Error      1              Program ‘c:\users\ben.hosking\documents\visual studio 2010\Projects\CRM\MetaData Extract\MetaData Extract\obj\x86\Debug\MetaData Extract.exe’ has more than one entry point defined: ‘MetaData_Extract.Program.Main(string[])’.  Compile with /main to specify the type that contains the entry point.                c:\users\ben.hosking\documents\visual studio 2010\Projects\CRM\MetaData Extract\MetaData Extract\Program.cs         23           21           MetaData Extract

This was a pretty straight forward problem, it’s saying my project has many entry points.  At this point I was just trying to get some of the CRM samples to work.

Finally I figured out that I had a few console type applications which were all self running code, e.g. more than one of my classes had a main function and Visual studio was saying it didn’t know which one to run first.

The way to fix this is to right click on the project

Select one of the classes in the Startup object.

This is also a good tip for running the CRM 2011 samples.  I was looking at the entity project.  This included 5 different class files.

The problem I had I wasn’t sure what class was going to run first, on web applications you set a default page to run first but I wasn’t sure

What happened when you had multiple classes in a console project.

Well the answer as I’m sure most of you already knew was you go into the project properties and select the start up object.

You live and learn people.  This is one example of noddy things I have missed out on because I didn’t go through the learning basics of .NET and was working on projects which were already half built.  I find I have some stupid and basic gaps in my knowledge but thanks to working on CRM 2011 I am learning some of the basics and some of the new functionality in .NET 4, like Linq etc.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.