Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
Do not throw if assembly cannot be loaded (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
SzymonPobiega authored and timbussmann committed Aug 15, 2017
1 parent 55d5df4 commit 462a63a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/NServiceBus.FileBasedRouting.Tests/XmlRoutingFileTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,25 @@ public void It_provides_distinct_result_even_when_types_are_registered_multiple_
CollectionAssert.AreEquivalent(new[] { typeof(A), typeof(B) }, configuration.Commands);
}

[Test]
public void It_does_not_throw_if_assembly_cannot_be_found()
{
const string xml = @"
<endpoints>
<endpoint name=""EndpointName"">
<handles>
<commands assembly = ""FooBar"" />
</handles>
</endpoint>
</endpoints>
";
var configurations = GetConfigurations(xml);

Assert.AreEqual(1, configurations.Length);
var configuration = configurations[0];
Assert.AreEqual("EndpointName", configuration.LogicalEndpointName);
}


static EndpointRoutingConfiguration[] GetConfigurations(string xml)
{
Expand Down
12 changes: 11 additions & 1 deletion src/NServiceBus.FileBasedRouting/XmlRoutingFileParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,17 @@ static Type FindMessageType(string typeName)
static IEnumerable<Type> SelectMessages(XElement commandsElement)
{
var assemblyName = commandsElement.Attribute("assembly").Value;
var assembly = Assembly.Load(assemblyName);
Assembly assembly;
try
{
assembly = Assembly.Load(assemblyName);
}
catch
{
logger.Warn($"Cannot add route for unknown assembly {assemblyName}.");
return Enumerable.Empty<Type>();
}

var exportedTypes = assembly.ExportedTypes;
var @namespace = commandsElement.Attribute("namespace");
if (@namespace == null)
Expand Down

0 comments on commit 462a63a

Please sign in to comment.