Add exception handling around directory name parsing.
Fixes [AMQNET-337]. (See https://issues.apache.org/jira/browse/AMQNET-337)



Project: http://git-wip-us.apache.org/repos/asf/activemq-nms-api/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-nms-api/commit/3c2315d6
Tree: http://git-wip-us.apache.org/repos/asf/activemq-nms-api/tree/3c2315d6
Diff: http://git-wip-us.apache.org/repos/asf/activemq-nms-api/diff/3c2315d6

Branch: refs/heads/1.5.x
Commit: 3c2315d6aee82aab3e8db844dc9e1dad3aae344c
Parents: 27cf9a1
Author: Jim Gomes <jgo...@apache.org>
Authored: Mon Oct 17 18:34:25 2011 +0000
Committer: Jim Gomes <jgo...@apache.org>
Committed: Mon Oct 17 18:34:25 2011 +0000

----------------------------------------------------------------------
 src/main/csharp/NMSConnectionFactory.cs | 34 ++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-nms-api/blob/3c2315d6/src/main/csharp/NMSConnectionFactory.cs
----------------------------------------------------------------------
diff --git a/src/main/csharp/NMSConnectionFactory.cs 
b/src/main/csharp/NMSConnectionFactory.cs
index 015786d..2c1d323 100644
--- a/src/main/csharp/NMSConnectionFactory.cs
+++ b/src/main/csharp/NMSConnectionFactory.cs
@@ -314,18 +314,34 @@ namespace Apache.NMS
                        // Check the current folder first.
                        pathList.Add("");
 #if !NETCF
-                       AppDomain currentDomain = AppDomain.CurrentDomain;
-
-                       // Check the folder the assembly is located in.
-                       
pathList.Add(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
-                       if(null != currentDomain.BaseDirectory)
+                       try
                        {
-                               pathList.Add(currentDomain.BaseDirectory);
-                       }
+                               AppDomain currentDomain = 
AppDomain.CurrentDomain;
 
-                       if(null != currentDomain.RelativeSearchPath)
+                               // Check the folder the assembly is located in.
+                               Assembly executingAssembly = 
Assembly.GetExecutingAssembly();
+                               try
+                               {
+                                       
pathList.Add(Path.GetDirectoryName(executingAssembly.Location));
+                               }
+                               catch(Exception ex)
+                               {
+                                       Tracer.DebugFormat("Error parsing 
executing assembly location: {0} : {1}", executingAssembly.Location, 
ex.Message);
+                               }
+
+                               if(null != currentDomain.BaseDirectory)
+                               {
+                                       
pathList.Add(currentDomain.BaseDirectory);
+                               }
+
+                               if(null != currentDomain.RelativeSearchPath)
+                               {
+                                       
pathList.Add(currentDomain.RelativeSearchPath);
+                               }
+                       }
+                       catch(Exception ex)
                        {
-                               pathList.Add(currentDomain.RelativeSearchPath);
+                               Tracer.DebugFormat("Error configuring search 
paths: {0}", ex.Message);
                        }
 #endif
 

Reply via email to