This repository was archived by the owner on Sep 2, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
NServiceBus.FileBasedRouting.Tests
NServiceBus.FileBasedRouting Expand file tree Collapse file tree 2 files changed +30
-1
lines changed 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_
120
120
CollectionAssert . AreEquivalent ( new [ ] { typeof ( A ) , typeof ( B ) } , configuration . Commands ) ;
121
121
}
122
122
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
+
123
142
124
143
static EndpointRoutingConfiguration [ ] GetConfigurations ( string xml )
125
144
{
Original file line number Diff line number Diff line change @@ -82,7 +82,17 @@ static Type FindMessageType(string typeName)
82
82
static IEnumerable < Type > SelectMessages ( XElement commandsElement )
83
83
{
84
84
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
+
86
96
var exportedTypes = assembly . ExportedTypes ;
87
97
var @namespace = commandsElement . Attribute ( "namespace" ) ;
88
98
if ( @namespace == null )
You can’t perform that action at this time.
0 commit comments