Is it possible to execute an arbitrary class in C# with a Main method, similar to that in Java? -


i've had migrate c# world. coming java land, add public static void main(string[] args) method class , select run class eclipse/netbeans code/logic wanted test.

is there equivalent of same capability in c#.net/visual studio? i've tried doing , best can execute command prompt via csc.exe. however, reason, complains not finding relevant dlls - seems expect run class in complete isolation without dependency on "external code" (i.e., code residing in vs project/solution class resides).

reason capability: project files marked class libraries , wish check if particular set of methods/data/logic work expected current code base. in java, i'd write in main method , execute class see how goes prior committing version control. however, there seems no easy way trigger execution of "my class" dependencies correctly handled csc.exe

current solution: add testing code unit test project , select execute particular "test" check if idea seems work fine (it may fire db calls or webservice class etc., , not purely logical flow of computation). seems work fine , current way of doing things. wondering if main method possible/recommended.

question: possible c#/vs or not recommended?

update: can't add console project achieve since addition of projects tightly controlled source control team. hence question of main method 'hack' quick , dirty checks/tests.

your project type needs console application "recognize" program.main method, not class library. intent class library encapsulated grouping of functionality can accessed project set allow user input. can console application, web project (mvc/api), or desktop (wpf).

if want execute test against code within class library project, can create unit test project, add reference , execute explicit tests against functionality you're looking achieve.

you can find out differences between different project types examining .csproj files in favorite text editor.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -