@@ -21,12 +21,13 @@ public static class ApplicationInfoFactory
2121 /// <returns>Current Application Information.</returns>
2222 public static ApplicationInfo CreateCurrentApplicationInfo ( )
2323 {
24+ Assembly asm = Assembly . GetEntryAssembly ( ) ;
2425 ApplicationInfo currApp = new ApplicationInfo {
2526 Name = Path . GetFileName ( System . Environment . GetCommandLineArgs ( ) [ 0 ] ) ,
26- Version = Assembly . GetExecutingAssembly ( ) . GetName ( ) . Version . ToString ( ) ,
27- ExecutingDirectory = GetExecutingDirectory ( ) ,
27+ Version = asm . GetName ( ) . Version . ToString ( ) ,
28+ ExecutingDirectory = GetExecutingDirectory ( asm ) ,
2829 CommandArguments = System . Environment . GetCommandLineArgs ( ) ,
29- CompanyName = FileVersionInfo . GetVersionInfo ( Assembly . GetEntryAssembly ( ) . Location ) . CompanyName
30+ CompanyName = FileVersionInfo . GetVersionInfo ( asm . Location ) . CompanyName
3031 } ;
3132 currApp . FilePath = Path . Combine ( currApp . ExecutingDirectory , currApp . Name ?? "" ) ;
3233
@@ -36,15 +37,16 @@ public static ApplicationInfo CreateCurrentApplicationInfo()
3637 /// <summary>
3738 /// Returns the application directory.
3839 /// </summary>
40+ /// <param name="asm">Assembly to the Executing Directory from.</param>
3941 /// <returns>Application Directory.</returns>
40- private static string GetExecutingDirectory ( )
42+ private static string GetExecutingDirectory ( Assembly asm )
4143 {
4244 string replaceText = "file://" ;
4345 if ( ExecutingEnvironment . LocalPlatform . OsPlatform == OsPlatformType . Windows ) {
4446 replaceText = "file:///" ;
4547 }
4648
47- string codeBase = Assembly . GetExecutingAssembly ( ) . GetName ( ) . CodeBase . Replace ( replaceText , "" ) ;
49+ string codeBase = asm . GetName ( ) . CodeBase . Replace ( replaceText , "" ) ;
4850 return Path . GetDirectoryName ( codeBase ) ;
4951 }
5052 }
0 commit comments