Mono.Zeroconf
/trunk/src/Mono.Zeroconf/Mono.Zeroconf.Providers/ProviderFactory.cs |
@@ -89,20 +89,31 @@ |
|
directories.Add(Path.Combine(new_path, "mono-zeroconf")); |
} |
|
foreach(string directory in directories) { |
foreach(string file in Directory.GetFiles(directory, "Mono.Zeroconf.Providers.*.dll")) { |
if(Path.GetFileName(file) != Path.GetFileName(this_asm_path)) { |
Assembly provider_asm = Assembly.LoadFile(file); |
foreach(Attribute attr in provider_asm.GetCustomAttributes(false)) { |
if(attr is ZeroconfProviderAttribute) { |
Type type = (attr as ZeroconfProviderAttribute).ProviderType; |
IZeroconfProvider provider = (IZeroconfProvider)Activator.CreateInstance(type); |
try { |
provider.Initialize(); |
providers_list.Add(provider); |
} catch (Exception e) { |
Console.WriteLine (e); |
|
try |
{ |
foreach (string directory in directories) |
{ |
foreach (string file in Directory.GetFiles(directory, "Mono.Zeroconf.Providers.*.dll")) |
{ |
if (Path.GetFileName(file) != Path.GetFileName(this_asm_path)) |
{ |
Assembly provider_asm = Assembly.LoadFile(file); |
foreach (Attribute attr in provider_asm.GetCustomAttributes(false)) |
{ |
if (attr is ZeroconfProviderAttribute) |
{ |
Type type = (attr as ZeroconfProviderAttribute).ProviderType; |
IZeroconfProvider provider = (IZeroconfProvider) Activator.CreateInstance(type); |
try |
{ |
provider.Initialize(); |
providers_list.Add(provider); |
} |
catch (Exception e) |
{ |
Console.WriteLine(e); |
} |
} |
} |
} |
@@ -109,7 +120,11 @@ |
} |
} |
} |
|
catch |
{ |
// Could not load a provider. |
} |
|
if(providers_list.Count == 0) { |
throw new Exception("No Zeroconf providers could be found or initialized. Necessary daemon may not be running."); |
} |