非常奇怪的问题...我在我的解决方案中有两个控制台应用程序,控制台应用程序1,确实显示控制台,当我运行它并将其设置为启动项目时。 。控制台应用程序2,运行...执行...但不显示控制台。为什么我的控制台应用程序没有显示控制台
下面是代码:
public class Program
{
static void Main()
{
string baseAddress = "http://localhost:8080/";
using (WebApp.Start<StartUp>(url: baseAddress))
{
Console.Write("Service Listening at : " + baseAddress);
System.Threading.Thread.Sleep(-1);
}
}
}
这里是类时启动Main
方法返回,除非一个子线程标记为前台线程
public class StartUp
{
public void Configuration(IAppBuilder appBuilder)
{
HttpConfiguration config = new HttpConfiguration();
config.EnableCors();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional });
config.Formatters.Clear();
config.Formatters.Add(new JsonMediaTypeFormatter());
config.Formatters.JsonFormatter.SerializerSettings =
new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
};
appBuilder.UseWebApi(config);
}
}
你是否已经在调试器中检查了应用程序,看它是否命中了Console.Write? – mrogers
是的,我有,它确实有效,然后我改变了启动并重建它,然后 –
告诉我们两个**控制台应用程序的代码 – MickyD