423,849 Members | 1,901 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,849 IT Pros & Developers. It's quick & easy.

How Do I make Multiple "Entry Points" in a .NET CORE app?

P: 65
I am new to .NET CORE but I have followed a few tutorials. The tutorials I have followed are basically "Hello World" types of programs where I make a small functional .Net Core application and I publish it. They are basically a DLL, I assume, and they run in some sort of system/container where they can run on any OS.

Even though the final product is a DLL, the code itself seems to be structured in a way where it is an actual executable application.

So how would I translate an actual C# DLL project into a .NET Core project? How would a project that is already designed to produce a DLL work in a .Net Core project?

Executables only have one entry point: static void Main.

.NET Libraries expose public methods which are all entry points in that sense.

An "entry point" in a program is where the operating system invokes an executable program file, the term does not apply to libraries. (and ASP.NET web-application files are really just libraries, the ASP.NET host just looks for certain exposed Page/Handler/Controller types). This applies to ASP.NET. Does it also apply to .NET Core? Also, when I ran my .NET Core applications, I did it from a special command line. So how would that work if I translated a DLL C# program into a .NET Core program?
Apr 11 '18 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 946
If you create a Library (a .DLL) like this:
Expand|Select|Wrap|Line Numbers
  1. namespace SharedLibrary
  2. {
  3.     public class myLibrary
  4.     {
  5.         public static string one()
  6.         {
  7.             return "one";
  8.         }
  10.         public static string two()
  11.         {
  12.             return "two";
  13.         }
  14.     }
  15. }
Than it will habe two entry-point (as you call them);

In a console application you can than to this:
Expand|Select|Wrap|Line Numbers
  1. using SharedLibrary;
  3. namespace TestSharedLibrary
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Console.WriteLine(SharedLibrary.myLibrary.one());
  10.             Console.WriteLine(SharedLibrary.myLibrary.two());
  11.         }
  12.     }
  13. }
This gives as output:
Expand|Select|Wrap|Line Numbers
  1. one
  2. two
Apr 14 '18 #2

Post your reply

Sign in to post your reply or Sign up for a free account.