Hello, I'm creating an installer for an Office Add-in that uses some .NET components which requires changes in CASPOL. I've had some success creating the code groups using CASPOL in a custom action based on some code that I found for installing Office Add-ins using the Visual Studio Installer builder. I can get the add-in to work from my WiX installer if I just trust the entire installation folder. However, I cannot get the assembly to load during the install to apply security policy just to the assembly that needs it.
The specific line it fails on is: AssemblyName assemblyName = Assembly.LoadFile(assemblyPath).GetName(); The error message is: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Exception: Cannot create the security code group 'PMXA'. ---> System.IO.FileNotFoundException: The system cannot find the file specified. (Exception from HRESULT: 0x80070002) at System.Reflection.Assembly.nLoadFile(String path, Evidence evidence) at System.Reflection.Assembly.LoadFile(String path) at CasCustomAction.CustomActions.AddSecurityPolicy(Boolean machinePolicyLevel, String solutionCodeGroupName, String solutionCodeGroupDescription, String assemblyPath, String assemblyCodeGroupName, String assemblyCodeGroupDescription, Session session) --- End of inner exception stack trace --- at CasCustomAction.CustomActions.AddSecurityPolicy(Boolean machinePolicyLevel, String solutionCodeGroupName, String solutionCodeGroupDescription, String assemblyPath, String assemblyCodeGroupName, String assemblyCodeGroupDescription, Session session) at CasCustomAction.CustomActions.SetCas(Session session) --- End of inner exception stack trace --- at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean skipVisibilityChecks) 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) The assembly path used in the custom action looks correct to me and I've tested that the built assembly can load properly outside of the custom action. The relevant snippets of WIX are the following: <Fragment> <CustomAction Id='SetCas' BinaryKey='CasCustomAction' DllEntry='SetCas' Execute='immediate' Return='check'/> <CustomAction Id='RemoveCas' BinaryKey='CasCustomAction' DllEntry='RemoveCas' Execute='immediate' Return='check'/> <Binary Id='CasCustomAction' SourceFile='$(var.SolutionDir)CasCustomAction\bin\$(var.CasCustomAction.Configuration)\CasCustomAction.CA.dll'/> </Fragment> ... <InstallExecuteSequence> <Custom Action='SetCas' Before='InstallFinalize'>NOT Installed</Custom> <Custom Action='RemoveCas' Before='InstallFinalize'>Installed AND NOT UPGRADINGPRODUCTCODE</Custom> </InstallExecuteSequence> First, is there a better way to do CASPOL registration for a .NET assembly? Second, any ideas on the error I'm encountering? Should I run the custom action at a different step in the installer? After I get this fixed, I'll have a much better installer than the crazy spaghetti generated by Visual Studio. :) Thanks. Rob ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users