Answer the question
In order to leave comments, you need to log in
C#. Why can't you refer to a class in another project if that project doesn't have a Main() method?
Created solutions. I added 2 projects to it - A and B. For A, I indicated a link to B.
Project A:
class ClassStart
{
static void Main(string[] args)
{
Class2.Run();
}
}
class Class1
{
static void Main(string[] args) { }
}
public class Class2
{
public static void Run()
{
System.Console.WriteLine("hello");
System.Console.ReadLine();
}
}
Program "..." does not contain a static method "Main" suitable for entry point B
Answer the question
In order to leave comments, you need to log in
Look, I see two situations
1) Project A is an application, that is, it has an EXE extension. Project B is a plug-in library, that is, a dll.
2) Project A and Project B are both applications, that is, they have the EXE extension. (I'm assuming you are).
In order for the OS to start the application, it must find a MAIN method with a certain signature in it. This is a common entry point, so to speak, and therefore in the second case, both projects must have this method.
Let me give you a little extra. I will send you information about .net. The fact is that in .NET both .exe and .dll files are assemblies and they have an almost identical structure, the only difference is that a valid .exe assembly must have this same MAIN method.
I might blow your mind right now, but an application project can use references to both .dll and .exe .net assemblies, and I'm pretty sure I can refer the .exe assembly to the project's .dll assembly. such things
are usually in a solution (that is, in a solution) there is a project of a certain application that communicates with the user and there are library projects where some common code is taken out. but there are also solutions where all projects are library projects and there are no applications at all.
you can easily change the type of one of the projects to a class library and you will be happy.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question