本文整理汇总了C#中Microsoft.Deployment.WindowsInstaller.Session.Close方法的典型用法代码示例。如果您正苦于以下问题:C# Session.Close方法的具体用法?C# Session.Close怎么用?C# Session.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Deployment.WindowsInstaller.Session
的用法示例。
在下文中一共展示了Session.Close方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InvokeCustomAction
internal 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.IsNullOrEmpty(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(
"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;
}
}