diff --git a/src/c#/GeneralUpdate.Client/MySample.cs b/src/c#/GeneralUpdate.Client/MySample.cs index d45be174..64fc8ab7 100644 --- a/src/c#/GeneralUpdate.Client/MySample.cs +++ b/src/c#/GeneralUpdate.Client/MySample.cs @@ -19,7 +19,7 @@ internal class MySample { #region 推送功能 - private const string baseUrl = @"http://127.0.0.1:5001"; + private const string baseUrl = @"http://localhost:5051"; private const string hubName = "versionhub"; internal MySample() @@ -113,7 +113,7 @@ private Configinfo GetWindowsConfigInfo() //该对象用于主程序客户端与更新组件进程之间交互用的对象 var config = new Configinfo(); //本机的客户端程序应用地址 - config.InstallPath = @"F:\test\Run"; + config.InstallPath = @"D:\packet\source"; //更新公告网页 config.UpdateLogUrl = "https://www.baidu.com/"; //客户端当前版本号 @@ -125,9 +125,9 @@ private Configinfo GetWindowsConfigInfo() //更新组件更新包下载地址 config.UpdateUrl = $"{baseUrl}/versions/{config.AppType}/{config.ClientVersion}/{config.AppSecretKey}"; //更新程序exe名称 - config.AppName = "AutoUpdate.Core"; + config.AppName = "GeneralUpdate.Core"; //主程序客户端exe名称 - config.MainAppName = "AutoUpdate.ClientCore"; + config.MainAppName = "GeneralUpdate.ClientCore"; //主程序信息 var mainVersion = "1.1.1.1"; //主程序客户端更新包下载地址 diff --git a/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs b/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs index aa92529c..d5d74d58 100644 --- a/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs +++ b/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs @@ -255,7 +255,7 @@ private void ClearEnvironmentVariable() { try { - Environment.SetEnvironmentVariable("ProcessBase64", null, EnvironmentVariableTarget.Machine); + Environment.SetEnvironmentVariable("ProcessBase64", null, EnvironmentVariableTarget.User); } catch (SecurityException ex) { diff --git a/src/c#/GeneralUpdate.Core/Exceptions/CustomException/GeneralUpdateException.cs b/src/c#/GeneralUpdate.Core/Exceptions/CustomException/GeneralUpdateException.cs index 405337dc..258fc84c 100644 --- a/src/c#/GeneralUpdate.Core/Exceptions/CustomException/GeneralUpdateException.cs +++ b/src/c#/GeneralUpdate.Core/Exceptions/CustomException/GeneralUpdateException.cs @@ -15,8 +15,7 @@ public sealed class GeneralUpdateException : Exception, ISeriali private const String c_args = "Args"; private readonly TExceptionArgs m_args; - public TExceptionArgs Args - { get { return m_args; } } + public TExceptionArgs Args=> m_args; public GeneralUpdateException(String message = null, Exception innerException = null) : this(null, message, innerException) { diff --git a/src/c#/GeneralUpdate.Core/Exceptions/ThrowExceptionUtility.cs b/src/c#/GeneralUpdate.Core/Exceptions/ThrowExceptionUtility.cs index 013a2534..95c7cdbb 100644 --- a/src/c#/GeneralUpdate.Core/Exceptions/ThrowExceptionUtility.cs +++ b/src/c#/GeneralUpdate.Core/Exceptions/ThrowExceptionUtility.cs @@ -10,6 +10,12 @@ public static void ThrowGeneralUpdateException(ExceptionArgs args) #region Common + public static void ThrowIfNull(object obj) + { + if (obj == null) + Throw("Parameter cannot be null"); + } + /// /// Checks if an object is empty and throws an exception if it is /// diff --git a/src/c#/GeneralUpdate.Core/GeneralUpdateBootstrap.cs b/src/c#/GeneralUpdate.Core/GeneralUpdateBootstrap.cs index 10519c9a..4cc57610 100644 --- a/src/c#/GeneralUpdate.Core/GeneralUpdateBootstrap.cs +++ b/src/c#/GeneralUpdate.Core/GeneralUpdateBootstrap.cs @@ -2,6 +2,7 @@ using GeneralUpdate.Core.Domain.Entity; using GeneralUpdate.Core.Domain.Entity.Assembler; using GeneralUpdate.Core.Domain.Enum; +using GeneralUpdate.Core.Exceptions; using GeneralUpdate.Core.Strategys; using GeneralUpdate.Core.Utils; using System; @@ -21,7 +22,7 @@ private void Remote() { try { - var base64 = Environment.GetEnvironmentVariable("ProcessBase64", EnvironmentVariableTarget.Machine); + var base64 = Environment.GetEnvironmentVariable("ProcessBase64", EnvironmentVariableTarget.User); var processInfo = SerializeUtil.Deserialize(base64); Packet = ProcessAssembler.ToPacket(processInfo); Packet.AppType = AppType.UpgradeApp; diff --git a/src/c#/GeneralUpdate.Core/Strategys/PlatformWindows/WindowsStrategy.cs b/src/c#/GeneralUpdate.Core/Strategys/PlatformWindows/WindowsStrategy.cs index 9efa708d..7d46afeb 100644 --- a/src/c#/GeneralUpdate.Core/Strategys/PlatformWindows/WindowsStrategy.cs +++ b/src/c#/GeneralUpdate.Core/Strategys/PlatformWindows/WindowsStrategy.cs @@ -86,7 +86,7 @@ public override bool StartApp(string appName, int appType) switch (appType) { case AppType.ClientApp: - Environment.SetEnvironmentVariable("ProcessBase64", Packet.ProcessBase64, EnvironmentVariableTarget.Machine); + Environment.SetEnvironmentVariable("ProcessBase64", Packet.ProcessBase64, EnvironmentVariableTarget.User); WaitForProcessToStart(path, 20, () => WillMessageManager.Instance.Check()); break;