Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'samples/WebApi/Startup.cs')
-rw-r--r--samples/WebApi/Startup.cs6
1 files changed, 6 insertions, 0 deletions
diff --git a/samples/WebApi/Startup.cs b/samples/WebApi/Startup.cs
index c432519f5..ec0db593a 100644
--- a/samples/WebApi/Startup.cs
+++ b/samples/WebApi/Startup.cs
@@ -8,6 +8,7 @@ using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
@@ -27,6 +28,11 @@ namespace SampleWebApi
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
+ // Override automatic discovery of Application parts done by MVC. It is not compatible with single file compilation.
+ var applicationPartManager = new ApplicationPartManager();
+ applicationPartManager.ApplicationParts.Add(new AssemblyPart(typeof(Startup).Assembly));
+ services.Add(new ServiceDescriptor(typeof(ApplicationPartManager), applicationPartManager));
+
services.AddMvcCore().AddJsonFormatters();
}