This repository was archived by the owner on Sep 2, 2021. It is now read-only.
File tree Expand file tree Collapse file tree
NServiceBus.FileBasedRouting.Tests
NServiceBus.FileBasedRouting Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -120,6 +120,25 @@ public void It_provides_distinct_result_even_when_types_are_registered_multiple_
120120 CollectionAssert . AreEquivalent ( new [ ] { typeof ( A ) , typeof ( B ) } , configuration . Commands ) ;
121121 }
122122
123+ [ Test ]
124+ public void It_does_not_throw_if_assembly_cannot_be_found ( )
125+ {
126+ const string xml = @"
127+ <endpoints>
128+ <endpoint name=""EndpointName"">
129+ <handles>
130+ <commands assembly = ""FooBar"" />
131+ </handles>
132+ </endpoint>
133+ </endpoints>
134+ " ;
135+ var configurations = GetConfigurations ( xml ) ;
136+
137+ Assert . AreEqual ( 1 , configurations . Length ) ;
138+ var configuration = configurations [ 0 ] ;
139+ Assert . AreEqual ( "EndpointName" , configuration . LogicalEndpointName ) ;
140+ }
141+
123142
124143 static EndpointRoutingConfiguration [ ] GetConfigurations ( string xml )
125144 {
Original file line number Diff line number Diff line change @@ -82,7 +82,17 @@ static Type FindMessageType(string typeName)
8282 static IEnumerable < Type > SelectMessages ( XElement commandsElement )
8383 {
8484 var assemblyName = commandsElement . Attribute ( "assembly" ) . Value ;
85- var assembly = Assembly . Load ( assemblyName ) ;
85+ Assembly assembly ;
86+ try
87+ {
88+ assembly = Assembly . Load ( assemblyName ) ;
89+ }
90+ catch
91+ {
92+ logger . Warn ( $ "Cannot add route for unknown assembly { assemblyName } .") ;
93+ return Enumerable . Empty < Type > ( ) ;
94+ }
95+
8696 var exportedTypes = assembly . ExportedTypes ;
8797 var @namespace = commandsElement . Attribute ( "namespace" ) ;
8898 if ( @namespace == null )
You can’t perform that action at this time.
0 commit comments