[wix-users] DTF - rename of CustomAction.cs/.config causes failure to load custom action
phill.hogland at rimage.com
Thu Apr 28 14:33:18 PDT 2016
I added a DTF C# project to my existing WixCompilerExtension Solution, and I succeeded in creating a C++ Immediate CA using the great and flexible WcaUtils tools to schedule and drive the DTF C# deferred CA. After working through those issues and getting that pattern to work, I renamed the files, and class, from the names originally assigned by Votive.
If I change CustomAction.cs and CustomAction.config to another name and also change the name of the CustomAction class to match the new file names, then the host bundle fails at runtime. The basic problem is
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Installer/MSIF8CB.tmp-/RdpNetCAs.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8013101b). Probing terminated.
I did this by making copies of the CustomAction.cs and CustomAction.config, and renaming only the CustomAction class. When I exclude the new files and add the old CustomAction files back into the project (including the .config as content) the runtime failure is not observed and the custom action succeeds.
I have noticed that other folks sample snippets use a different class name than CustomAction so I assume that it is legitimit to try and change the name. Any insites on resolving this problem would be appreciated.
Also the project is built against NetFx 4.5.2 (as is my mba) and the config file does not indicate support of NetFx v2 however I found that even though I do not use useLegacyV2RuntimeActivationPolicy="true" in my mba as I target only Win7 and later, I had to add it just to compile the DTF project.
<?xml version="1.0" encoding="utf-8" ?>
<!-- DTF requires useLegacyV2RuntimeActivationPolicy when tarketing NetFx4 or higher, even on Win7 or later when v2 is not installed.-->
<startup useLegacyV2RuntimeActivationPolicy="true" >
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
The exception thrown is:
System.BadImageFormatException: Could not load file or assembly 'RdpNetCAs' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
File name: 'RdpNetCAs'
at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.AppDomain.Load(String assemblyString)
at Microsoft.Deployment.WindowsInstaller.CustomActionProxy.GetCustomActionMethod(Session session, String assemblyName, String className, String methodName)
Again any thoughts on how to rename the CustomAction class, (or clarification that I should not do this) and resolve this runtime problem would be appreciated.
More information about the wix-users