I have created an ADO.NET data provider that is built using AnyCPU. When referenced directly it works fine on both 64 and 32 bit Windows OS. However, in my installer, I register my DbProviderFactory with the .NET machine.config and place my assemblies in the GAC so users can access the data provider through System.Windows.DbProviderFactories. This works great as long as the application is running as 32-bit. It does not work for applications built for x64.
This is what I have found. My installer is targeted for 32 bit. Therefore, my DbProviderFactory only gets added to the 32-bit .NET machine.config. In order for x64 applications to use my data provider through the DbProviderFactories, it needs to be registered with the 64-bit .NET machine.config.
Do I have to have two installers? One targeting 32 and the other 64? All of my assemblies are AnyCPU (because I don't know or care what platform the user's application is).
My somewhat complex solution was this. During the installer, I have custom action that checks if the OS is 64-bit (here). If it is, I want to start a process that runs a 64 bit console app that will add my DbProviderFactory to the machine.config (64-bit). And my installer itself will register with the 32-bit machine.config. I tried and it failed since I cannot have a 64-bit assembly in a setup project that targets 32-bit. However, I am going to try to build the console app using AnyCPU assuming it will run as a 64-bit process on 64-bit OS's.
This is rather messy, but I think it will work. Why is this a bad idea? And why does microsoft say "To distribute a .NET Framework application both to 32- and 64-bit platforms, build two MSI packages, one targeted at a 32-bit and the other a 64-bit computer" (msdn). Will it work since technically all of my assemblies are AnyCPU?
Also, I'm using .NET 3.5