Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Commit

Permalink
#1075 Suppress exceptions from failing to load HostingStartup assemblies
Browse files Browse the repository at this point in the history
  • Loading branch information
Tratcher committed May 23, 2017
1 parent 68d1d4c commit 7ac6842
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
6 changes: 0 additions & 6 deletions src/Microsoft.AspNetCore.Hosting/WebHostBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,6 @@ private IServiceCollection BuildCommonServices(out AggregateException hostingSta
if (exceptions.Count > 0)
{
hostingStartupErrors = new AggregateException(exceptions);

// Throw directly if we're not capturing startup errors
if (!_options.CaptureStartupErrors)
{
throw hostingStartupErrors;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -975,17 +975,18 @@ public void Build_HostingStartupFromPrimaryAssemblyCanBeDisabled()
}

[Fact]
public void Build_ThrowsIfUnloadableAssemblyNameInHostingStartupAssemblies()
public void Build_DoesntThrowIfUnloadableAssemblyNameInHostingStartupAssemblies()
{
var builder = CreateWebHostBuilder()
.CaptureStartupErrors(false)
.UseSetting(WebHostDefaults.HostingStartupAssembliesKey, "SomeBogusName")
.Configure(app => { })
.UseServer(new TestServer());

var ex = Assert.Throws<AggregateException>(() => builder.Build());
Assert.IsType<InvalidOperationException>(ex.InnerExceptions[0]);
Assert.IsType<FileNotFoundException>(ex.InnerExceptions[0].InnerException);
using (builder.Build())
{
Assert.Equal("0", builder.GetSetting("testhostingstartup"));
}
}

[Fact]
Expand Down

0 comments on commit 7ac6842

Please sign in to comment.