You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have declared the project in the Main() method as follows:-
var project =
new ManagedProject("MyProduct",
new Dir(@"C:\",new Dir(@"MyWindowService", new DirFiles(@"..\MyWindowsService\bin\Release\*.*"))),
new ElevatedManagedAction(CustomActions.InstallService,
Return.check,
When.After,
Step.InstallFiles,
Condition.Always),
new ElevatedManagedAction(CustomActions.UnInstallService,
Return.check,
When.Before,
Step.RemoveFiles,
Condition.BeingRemoved));
I am assigning some value to Session["propertyName"] in the next button click event of the CustomDialog as follows:-
I am trying to access this value in the Custom Action InstallService method and Msi_AfterInstall method as follows:-
[CustomAction]
public static ActionResult InstallService(Session session)
{
var connectionString = session["ConnectionString"];
.........
}
static void Msi_AfterInstall(SetupEventArgs e)
{
var connectionString=e.Session["ConnectionString"];
...........
}
But the value is not accessible and its throwing below error for both the methods when I am trying to get the value from Session["propertyName"].
Errors:-
Info: Exception thrown by custom action:
Info: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.Deployment.WindowsInstaller.InstallerException: Cannot access session details from a non-immediate custom action
at Microsoft.Deployment.WindowsInstaller.Session.ValidateSessionAccess()
at Microsoft.Deployment.WindowsInstaller.Session.get_Item(String property)
at MySetup.CustomActions.InstallService(Session session) in H:\MySetup\CustomActions.cs:line 21
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object parameters, Object arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)
at Microsoft.Deployment.WindowsInstaller.CustomActionProxy.InvokeCustomAction(Int32 sessionHandle, String entryPoint, IntPtr remotingDelegatePtr)
Info: Calling custom action WixSharp!WixSharp.ManagedProjectActions.WixSharp_AfterInstall_Action
Info: WixSharp aborted the session because of the error:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.Deployment.WindowsInstaller.InstallerException: Cannot access session details from a non-immediate custom action
at Microsoft.Deployment.WindowsInstaller.Session.ValidateSessionAccess()
at Microsoft.Deployment.WindowsInstaller.Session.get_Item(String property)
at MySetup.Program.Msi_AfterInstall(SetupEventArgs e)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object parameters, Object arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)
at WixSharp.ManagedProject.InvokeClientHandler(String info, SetupEventArgs eventArgs)
at WixSharp.ManagedProject.InvokeClientHandlers(Session session, String eventName, IShellView UIShell)
Am I following some wrong syntax?
Please advise. Thanks in advance.
The text was updated successfully, but these errors were encountered:
The problem you are experiencing is due to the fact that MSI architecture does not allow you accessing the session properties from the deferred actions (see (Deferred Actions)[https://github.com/oleg-shilo/wixsharp/wiki/Deployment-scenarios#deferred-actions]). The DeferredActions and "Managed Setup/Setup Events" samples also shows the connection_string use-case:
Hi Oleg,
I have declared the project in the Main() method as follows:-
I am assigning some value to Session["propertyName"] in the next button click event of the CustomDialog as follows:-
I am trying to access this value in the Custom Action InstallService method and Msi_AfterInstall method as follows:-
But the value is not accessible and its throwing below error for both the methods when I am trying to get the value from Session["propertyName"].
Errors:-
Info: Exception thrown by custom action:
Info: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.Deployment.WindowsInstaller.InstallerException: Cannot access session details from a non-immediate custom action
at Microsoft.Deployment.WindowsInstaller.Session.ValidateSessionAccess()
at Microsoft.Deployment.WindowsInstaller.Session.get_Item(String property)
at MySetup.CustomActions.InstallService(Session session) in H:\MySetup\CustomActions.cs:line 21
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object parameters, Object arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)
at Microsoft.Deployment.WindowsInstaller.CustomActionProxy.InvokeCustomAction(Int32 sessionHandle, String entryPoint, IntPtr remotingDelegatePtr)
Info: Calling custom action WixSharp!WixSharp.ManagedProjectActions.WixSharp_AfterInstall_Action
Info: WixSharp aborted the session because of the error:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.Deployment.WindowsInstaller.InstallerException: Cannot access session details from a non-immediate custom action
at Microsoft.Deployment.WindowsInstaller.Session.ValidateSessionAccess()
at Microsoft.Deployment.WindowsInstaller.Session.get_Item(String property)
at MySetup.Program.Msi_AfterInstall(SetupEventArgs e)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object parameters, Object arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)
at WixSharp.ManagedProject.InvokeClientHandler(String info, SetupEventArgs eventArgs)
at WixSharp.ManagedProject.InvokeClientHandlers(Session session, String eventName, IShellView UIShell)
Am I following some wrong syntax?
Please advise. Thanks in advance.
The text was updated successfully, but these errors were encountered: