2017-07-20 35 views
0

無法在創建.NET Web API時在Visual Studio 2015中使用'swagger.net'。爲什麼? 我在創建基於.NET的Web API時遇到了一個錯誤。我已經安裝了swagger和相關的軟件包。在創建.net web api時無法在visual studio 2015中使用'swagger.net',爲什麼?

錯誤的:SwaggerActionFilter(),XmlCommentDocumentationProvider

我的功能是:

public static void PostStart() 
{ 
    var config = GlobalConfiguration.Configuration; 

    config.Filters.Add(new SwaggerActionFilter()); 

    try 
    { 
     config.Services.Replace(typeof(IDocumentationProvider), 
      new XmlCommentDocumentationProvider(HttpContext.Current.Server.MapPath("~/bin/DigiCob.XML"))); 
    } 
    catch (FileNotFoundException) 
    { 
     throw new Exception("Please enable \"XML documentation file\" in project properties with default (bin\\DigiCob.XML) value or edit value in App_Start\\SwaggerNet.cs"); 
    } 
} 

enter image description here

+0

誰編輯我的文章之前監測??? ... – Four

+0

您的帖子被剪輯,以削減你的發誓,因爲它是毫無意義的。不過,你是否在Visual Studio的Project References中添加了對DLL的引用? –

+0

很好...好的兄弟...可以請指導我這樣做... – Four

回答

1

的.NET實現揚鞭規範被稱爲Swashbuckle。

安裝Swashbuckle nuget包,你應該沒問題。

+0

我已經做了這個兄弟,不知道接下來要安裝什麼,我認爲唯一的方法是通過重新創建整個項目。 – Four

+0

您是否添加了正確的使用語句? –

+0

是的兄弟,我很確定,錯誤是爲了避免不必要的使用語句,我不能使用'使用Swagger.net'。 – Four

相關問題