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

Suppress exceptions from failing to load HostingStartup assemblies #1083

Merged
merged 1 commit into from
May 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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