File tree Expand file tree Collapse file tree 1 file changed +22
-4
lines changed
SimpleUpdater/FSLib.App.SimpleUpdater/Defination Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change 33 using System ;
44 using System . Collections . Generic ;
55 using System . Diagnostics ;
6+ using System . IO ;
67 using System . Net ;
78 using System . Net . Cache ;
89 using System . Reflection ;
@@ -21,11 +22,8 @@ public class UpdateContext
2122
2223 public UpdateContext ( )
2324 {
24- //CurrentVersion = new Version(FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location).FileVersion);
25- var processModule = Process . GetCurrentProcess ( ) . MainModule ;
25+ InitializeCurrentVersion ( ) ;
2626
27- CurrentVersion = new Version ( processModule . FileVersionInfo . FileVersion ) ;
28- ApplicationDirectory = System . IO . Path . GetDirectoryName ( processModule . FileName ) ;
2927 AutoEndProcessesWithinAppDir = true ;
3028 ExternalProcessID = new List < int > ( ) ;
3129 ExternalProcessName = new List < string > ( ) ;
@@ -68,6 +66,26 @@ public UpdateContext()
6866 AppendRandomTagInDownloadUrl = true ;
6967 }
7068
69+ /// <summary>
70+ /// 初始化当前的版本信息
71+ /// </summary>
72+ void InitializeCurrentVersion ( )
73+ {
74+ var assembly = Assembly . GetEntryAssembly ( ) ;
75+ if ( assembly != null )
76+ {
77+ CurrentVersion = new Version ( FileVersionInfo . GetVersionInfo ( assembly . Location ) . FileVersion ) ;
78+ ApplicationDirectory = Path . GetDirectoryName ( assembly . Location ) ;
79+ }
80+ else
81+ {
82+ var processModule = Process . GetCurrentProcess ( ) . MainModule ;
83+
84+ CurrentVersion = new Version ( processModule . FileVersionInfo . FileVersion ) ;
85+ ApplicationDirectory = System . IO . Path . GetDirectoryName ( processModule . FileName ) ;
86+ }
87+ }
88+
7189 /// <summary>
7290 /// 尝试从程序集中获得升级属性
7391 /// </summary>
You can’t perform that action at this time.
0 commit comments