本文整理汇总了C#中Session.Log方法的典型用法代码示例。如果您正苦于以下问题:C# Session.Log方法的具体用法?C# Session.Log怎么用?C# Session.Log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Session
的用法示例。
在下文中一共展示了Session.Log方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdatePSShortcut
public static ActionResult UpdatePSShortcut(Session session)
{
Thread staThread = new Thread(RunSTAThread);
staThread.SetApartmentState(ApartmentState.STA);
staThread.Start(session);
// Wait for the new thread to finish its operations
staThread.Join();
// If there is any exception in the new thread pass it to the installer
if (_STAThreadException != null)
{
session.Log(_STAThreadException.Message);
return ActionResult.Failure;
}
return ActionResult.Success;
}
示例2: RegisterAscomDriver
public static ActionResult RegisterAscomDriver(Session session)
{
session.Log("Begin RegisterAscomDriver");
CreateTraceListener(session);
try
{
Diagnostics.TraceInfo("Begin RegisterAscomDriver custom action");
Type type = typeof(Dome);
Assembly assembly = type.Assembly;
//RegisterCom(assembly);
RegisterAscom(assembly);
Diagnostics.TraceInfo("RegisterAscomDriver custom action successful.");
return ActionResult.Success;
}
catch (Exception e)
{
Diagnostics.TraceInfo("RegisterAscomDriver custom action failed: {0}", e);
return ActionResult.Failure;
}
}
示例3: Connect
/// <summary>
/// Connects to the server, creates a Session, optionally enables SSL/TLS 1.2
/// and begins an asynchronous socket read operation.
/// </summary>
public void Connect()
{
Close();
streamSocket = new StreamSocket();
streamSocket.Control.NoDelay = true;
HostName hostName = new HostName(ServerConfiguration.Host);
if (ServerConfiguration.TlsConfiguration != null && ServerConfiguration.TlsConfiguration.Enabled)
{
try
{
IAsyncAction aa = streamSocket.ConnectAsync(hostName, ServerConfiguration.Port.ToString(), SocketProtectionLevel.Tls12);
aa.AsTask().Wait();
}
catch (Exception ex)
{
if (streamSocket.Information.ServerCertificateErrorSeverity != SocketSslErrorSeverity.Ignorable)
throw ex.InnerException != null ? ex.InnerException : ex;
foreach (ChainValidationResult error in streamSocket.Information.ServerCertificateErrors)
{
switch (error)
{
case ChainValidationResult.IncompleteChain:
if (ServerConfiguration.TlsConfiguration.AllowCertificateChainErrors)
streamSocket.Control.IgnorableServerCertificateErrors.Add(error);
break;
case ChainValidationResult.Untrusted:
if (ServerConfiguration.TlsConfiguration.AllowSelfSignedCertificate)
streamSocket.Control.IgnorableServerCertificateErrors.Add(error);
break;
case ChainValidationResult.Revoked:
if (ServerConfiguration.TlsConfiguration.CheckCertificateRevocation)
streamSocket.Control.IgnorableServerCertificateErrors.Add(error);
break;
default:
throw ex.InnerException != null ? ex.InnerException : ex;
}
}
IAsyncAction aa = streamSocket.ConnectAsync(hostName, ServerConfiguration.Port.ToString(), SocketProtectionLevel.Tls12);
try
{
aa.AsTask().Wait();
}
catch (Exception ex2)
{
throw ex2.InnerException != null ? ex2.InnerException : ex2;
}
}
}
else
{
IAsyncAction aa = streamSocket.ConnectAsync(hostName, ServerConfiguration.Port.ToString());
try
{
aa.AsTask().Wait();
}
catch (Exception ex)
{
throw ex.InnerException != null ? ex.InnerException : ex;
}
}
session = new Session(streamSocket, hostName.DisplayName, ServerConfiguration.TlsConfiguration, ProtocolConfigurations, Logger, UserData);
session.OnConnectionLost += session_OnConnectionLost;
session.Log(Level.Info, string.Format("Connected to {0}:{1}...", ServerConfiguration.Host, ServerConfiguration.Port));
session.BeginRead();
}
示例4: InvokeCustomAction
public static int InvokeCustomAction(int sessionHandle, string entryPoint,
IntPtr remotingDelegatePtr)
{
Session session = null;
string assemblyName, className, methodName;
MethodInfo method;
try
{
MsiRemoteInvoke remotingDelegate = (MsiRemoteInvoke)
Marshal.GetDelegateForFunctionPointer(
remotingDelegatePtr, typeof(MsiRemoteInvoke));
RemotableNativeMethods.RemotingDelegate = remotingDelegate;
sessionHandle = RemotableNativeMethods.MakeRemoteHandle(sessionHandle);
session = new Session((IntPtr) sessionHandle, false);
if (string.IsNullOrWhiteSpace(entryPoint))
{
throw new ArgumentNullException("entryPoint");
}
if (!CustomActionProxy.FindEntryPoint(
session,
entryPoint,
out assemblyName,
out className,
out methodName))
{
return (int) ActionResult.Failure;
}
session.Log("Calling custom action {0}!{1}.{2}", assemblyName, className, methodName);
method = CustomActionProxy.GetCustomActionMethod(
session,
assemblyName,
className,
methodName);
if (method == null)
{
return (int) ActionResult.Failure;
}
}
catch (Exception ex)
{
if (session != null)
{
try
{
session.Log("Exception while loading custom action:");
session.Log(ex.ToString());
}
catch (Exception) { }
}
return (int) ActionResult.Failure;
}
try
{
// Set the current directory to the location of the extracted files.
Environment.CurrentDirectory =
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
object[] args = new object[] { session };
if (DebugBreakEnabled(new string[] { entryPoint, methodName }))
{
string message = String.Format(CultureInfo.InvariantCulture,
"To debug your custom action, attach to process ID {0} (0x{0:x}) and click OK; otherwise, click Cancel to fail the custom action.",
System.Diagnostics.Process.GetCurrentProcess().Id
);
MessageResult button = NativeMethods.MessageBox(
IntPtr.Zero,
message,
"Custom Action Breakpoint",
(int)MessageButtons.OKCancel | (int)MessageIcon.Asterisk | (int)(MessageBoxStyles.TopMost | MessageBoxStyles.ServiceNotification)
);
if (MessageResult.Cancel == button)
{
return (int)ActionResult.UserExit;
}
}
ActionResult result = (ActionResult) method.Invoke(null, args);
session.Close();
return (int) result;
}
catch (InstallCanceledException)
{
return (int) ActionResult.UserExit;
}
catch (Exception ex)
{
session.Log("Exception thrown by custom action:");
session.Log(ex.ToString());
return (int) ActionResult.Failure;
}
}
示例5: GetCustomActionMethod
private static MethodInfo GetCustomActionMethod(
Session session,
string assemblyName,
string className,
string methodName)
{
Assembly customActionAssembly;
Type customActionClass = null;
Exception caughtEx = null;
try
{
customActionAssembly = AppDomain.CurrentDomain.Load(assemblyName);
customActionClass = customActionAssembly.GetType(className, true, true);
}
catch (IOException ex) { caughtEx = ex; }
catch (BadImageFormatException ex) { caughtEx = ex; }
catch (TypeLoadException ex) { caughtEx = ex; }
catch (ReflectionTypeLoadException ex) { caughtEx = ex; }
catch (SecurityException ex) { caughtEx = ex; }
if (caughtEx != null)
{
session.Log("Error: could not load custom action class " + className + " from assembly: " + assemblyName);
session.Log(caughtEx.ToString());
return null;
}
MethodInfo[] methods = customActionClass.GetMethods(
BindingFlags.Public | BindingFlags.Static);
foreach (MethodInfo method in methods)
{
if (method.Name == methodName &&
CustomActionProxy.MethodHasCustomActionSignature(method))
{
return method;
}
}
session.Log("Error: custom action method \"" + methodName +
"\" is missing or has the wrong signature.");
return null;
}
示例6: FindEntryPoint
private static bool FindEntryPoint(
Session session,
string entryPoint,
out string assemblyName,
out string className,
out string methodName)
{
assemblyName = null;
className = null;
methodName = null;
string fullEntryPoint;
if (entryPoint.IndexOf('!') > 0)
{
fullEntryPoint = entryPoint;
}
else
{
IDictionary config;
try
{
config = (IDictionary) ConfigurationManager.GetSection("customActions");
}
catch (ConfigurationException cex)
{
session.Log("Error: missing or invalid customActions config section.");
session.Log(cex.ToString());
return false;
}
fullEntryPoint = (string) config[entryPoint];
if (fullEntryPoint == null)
{
session.Log(
"Error: custom action entry point '{0}' not found " +
"in customActions config section.",
entryPoint);
return false;
}
}
int assemblySplit = fullEntryPoint.IndexOf('!');
int methodSplit = fullEntryPoint.LastIndexOf('.');
if (assemblySplit < 0 || methodSplit < 0 || methodSplit < assemblySplit)
{
session.Log("Error: invalid custom action entry point:" + entryPoint);
return false;
}
assemblyName = fullEntryPoint.Substring(0, assemblySplit);
className = fullEntryPoint.Substring(assemblySplit + 1, methodSplit - assemblySplit - 1);
methodName = fullEntryPoint.Substring(methodSplit + 1);
return true;
}
示例7: Initialize
public static int Initialize(int sessionHandle, string uiClass, int internalUILevel)
{
Session session = null;
try
{
session = new Session((IntPtr) sessionHandle, false);
if (string.IsNullOrWhiteSpace(uiClass))
{
throw new ArgumentNullException("uiClass");
}
EmbeddedUIProxy.uiInstance = EmbeddedUIProxy.InstantiateUI(session, uiClass);
}
catch (Exception ex)
{
if (session != null)
{
try
{
session.Log("Exception while loading embedded UI:");
session.Log(ex.ToString());
}
catch (Exception)
{
}
}
}
if (EmbeddedUIProxy.uiInstance == null)
{
return (int) ActionResult.Failure;
}
try
{
string resourcePath = Path.GetDirectoryName(EmbeddedUIProxy.uiInstance.GetType().Assembly.Location);
InstallUIOptions uiOptions = (InstallUIOptions) internalUILevel;
if (EmbeddedUIProxy.DebugBreakEnabled("Initialize"))
{
System.Diagnostics.Debugger.Launch();
}
if (EmbeddedUIProxy.uiInstance.Initialize(session, resourcePath, ref uiOptions))
{
// The embedded UI initialized and the installation should continue
// with internal UI reset according to options.
return ((int) uiOptions) << 16;
}
else
{
// The embedded UI did not initialize but the installation should still continue
// with internal UI reset according to options.
return (int) uiOptions;
}
}
catch (InstallCanceledException)
{
// The installation was canceled by the user.
return (int) ActionResult.UserExit;
}
catch (Exception ex)
{
// An unhandled exception causes the installation to fail immediately.
session.Log("Exception thrown by embedded UI initialization:");
session.Log(ex.ToString());
return (int) ActionResult.Failure;
}
}
示例8: InstantiateUI
private static IEmbeddedUI InstantiateUI(Session session, string uiClass)
{
int assemblySplit = uiClass.IndexOf('!');
if (assemblySplit < 0)
{
session.Log("Error: invalid embedded UI assembly and class:" + uiClass);
return null;
}
string assemblyName = uiClass.Substring(0, assemblySplit);
EmbeddedUIProxy.uiClass = uiClass.Substring(assemblySplit + 1);
Assembly uiAssembly;
try
{
uiAssembly = AppDomain.CurrentDomain.Load(assemblyName);
// This calls out to CustomActionProxy.DebugBreakEnabled() directly instead
// of calling EmbeddedUIProxy.DebugBreakEnabled() because we don't compose a
// class.method name for this breakpoint.
if (CustomActionProxy.DebugBreakEnabled(new string[] { "EmbeddedUI" }))
{
System.Diagnostics.Debugger.Launch();
}
return (IEmbeddedUI) uiAssembly.CreateInstance(EmbeddedUIProxy.uiClass);
}
catch (Exception ex)
{
session.Log("Error: could not load embedded UI class " + EmbeddedUIProxy.uiClass + " from assembly: " + assemblyName);
session.Log(ex.ToString());
return null;
}
}