We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

devnull
Posts: 9
Joined: Tue Aug 16, 2016 2:47 pm

Custom Action Data (C# KeyNotFoundException)

Hi,

sometimes a custom action fails with the following exception:

Code: Select all

SFXCA: Extracting custom action to temporary directory: C:\Windows\Installer\MSI31337.tmp-\
SFXCA: Binding to CLR version v4.0.30319
Calling custom action Installer.CustomAction!Installer.CustomAction.CustomAction.DoSomething
CA__ (DLL) DoSomething: CA__BEGIN ...
Exception thrown by custom action:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   bei System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   bei Microsoft.Deployment.WindowsInstaller.CustomActionData.get_Item(String key)
   bei Installer.CustomAction.CustomAction.DoSomething(Session session)
   --- End of the inner exception stack trace. ---
   bei System.RuntimeMethodHandle.InvokeMethod(Object target, Object arguments, Signature sig, Boolean constructor)
   bei System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object parameters, Object arguments)
   bei System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)
   bei Microsoft.Deployment.WindowsInstaller.CustomActionProxy.InvokeCustomAction(Int32 sessionHandle, String entryPoint, IntPtr remotingDelegatePtr)
CustomAction CA__DoSomething returned actual error code 1603 but will be translated to success due to continue marking
Action ended 13:33:37: CA__DoSomething. Return value 1603.
Inside the AIP project following parameters are passed:
ProductName=[ProductName];ProductVersion=[ProductVersion];AppDir=[SETUPEXEDIR]

Stage of the custom action is between "Paths Resolution" and "Preparing".

Inside the action following parameters are retrieved:
session.CustomActionData["AppDir"], session.CustomActionData["ProductName"], session.CustomActionData["ProductVersion"]

How can this happen?

Thank you,
/dev/null
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Custom Action Data (C# KeyNotFoundException)

Hi,

I apologize for the delayed reply.

I'm not sure why you encounter this problem. However, since your custom action is placed between the "Paths Resolution" and the "Preparing" action groups it is an immediate custom action, so you should access the properties as described in the "Get and set a property in a DTF C# custom action" article.

The "CustomActionData" special property is necessary only when you want to use properties in a deferred custom action.

You can also try to debug your custom action as detailed in the "How to integrate and debug custom actions" article.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”