2016-05-14 83 views
-4

我试图建立这个代码按下Ctrl + Alt + F5:大厦C#的lib

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 

namespace Formater 
{ 
    public class Startup 
    { 
     public async Task <object> Invoke (object input) 
     { 
      return ".NET"; 
     } 
    } 
} 

,但我收到此错误:

“与一个类库输出类型项目不能直接启动

为了调试这个项目,将一个可执行项目添加到引用库项目的解决方案中,将可执行项目设置为启动项目。

可能是什么问题?我在寻找特种部队的问题,我发现了几个解决方案,但他们都没有工作。

谢谢。

+0

F5不适合建筑,它适合跑步。使用F6进行建筑。 – NineBerry

回答

1

您正在构建一个没有任何入口点或主要方法的类库。你不能单独运行类库,你只能建造它,运行这个类库你要么必须添加它会console appwin form或任何.NET应用程序

4

What could be the problem?

的至于你说:

A Project with an output type of Class Library cannot be started directly

如此下去 - 如果你懒得阅读:

In order to debug this project, add an executable project to this solution which references the library project. Set the executable project as the startup project.

这一切都是清晰的英语。类库(dll)没有入口点,无法启动。这是一个在程序中使用的库。

1

由于您正在构建库(.dll),因此Visual Studio不知道如何运行它。 Visual Studio只能运行由Web服务器加载的程序(.exe)或网站(以及其他内容)。

Visual Studio提供的解决方案基本上意味着您必须在其他一些程序中引用您的库才能运行它。