我制作了一个计算器程序。我做了四个项目。
GUI应用程序(WPF或控制台)效果很好!他们在依赖项中拥有“逻辑类库”。
现在,我想从我的客户端中选择他想要的GUI,所以我为他编写了Factory类库并将其设置为“启动项目”。
但是它不起作用,因为错误消息“无法直接启动类库”。
该怎么办?
感谢前进。
答案 0 :(得分:0)
类库不能是启动项目。它必须是exe,而不是dll。
我要做的是:
或
控制台应用程序或批处理可能还会读取某些注册表项,并基于该调用适当的执行程序。
答案 1 :(得分:0)
最简单的方法是创建另一个应用程序,它的唯一任务就是启动GUI版本或CLI版本。
您可以在专用的console application
中进行此操作,但随后会看到console box
弹出窗口一秒钟。
或者,您可以使用WinForms
应用程序并使用以下代码行:
using System.Diagnostics;
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string [] args)
{
// disable these lines:
//Application.EnableVisualStyles();
//Application.SetCompatibleTextRenderingDefault(false);
//Application.Run(new Form1());
//read settings file or parse arguments
//start the GUI or CLI process
Process process = new Process();
process.StartInfo.FileName = "some.exe";
process.Start();
//optional
process.WaitForExit();
}
}