问题
Is there any way to change my class library program into an .exe
or a click once-application? It is Currently a dll.
I am able to create a click once app but it is not working after installation.
回答1:
In the properties of the project -> application tag, change the Output type to console Application. Anyway, you need to create a static Main()
method as a starting point.
static void Main(string[] args)
{
}
回答2:
You can change the output type of your project in it's settings, then add a main entrypoint, as others have mentioned (Note, you want "Windows application", not "Console Application" here):
If you can't change the source for some reason, you can create a new very simple application (an .exe), and call public methods in your .dll from it:
namespace YourNamespace
{
internal class YourApp
{
private static void Main(string[] args)
{
// Call your function here.
}
}
}
To do this, you just need to include a reference to the existing .dll into this new application.
回答3:
Rather than changing it to an EXE - create a new project (Winform App, WPF, Console App, whatever) and reference your DLL to use the classes from it.
If you convert your DLL to an EXE then you lose (or at least significantly hinder) the ability to use those classes in any other application.
Keep non-UI classes in a DLL and only put UI-layer classes and controls in the executable.
回答4:
Within dotnet core, just add this to the csproj
, ideally within the first PropertyGroup
:
<OutputType>Exe</OutputType>
Just watch out if your target framework was netstandard
, that of course will not work (!).
来源:https://stackoverflow.com/questions/16236846/any-way-to-convert-class-library-function-into-exe