0

I have a .NET Application (VB Winforms) that runs a main executable. On startup this executable will search for plugins and will load them in using System.Reflection.Assembly.Load()

I then use interfaces to add menu icons from the plugins into the main app's icon bar so forms from the plugins can be shown .. You get the idea.

Now, this application currently runs with a Target platform of AnyCPU. My thinking behind this was so the application would work on both x86/x64 platforms. If installed on x86 it would have the 2GB memory limitation, but would also be available on x64 and run freely (This is how it works - Right?)

Now, i want to show help files from my Website inside an embedded browser - I've chosen CEFSharp Chromium Browser and it works brilliantly, however CEFSharp MUST have a Target Platform of either x86 or x64 specifically set.

I've created a plugin to hold the browser and set this project to a target platform of x86 (64 bit operating systems can still run x86 apps - So this should work for both), my thinking was that i could load this plugin into the application however when i do so i get the following error:

Could not load file or assembly 'XIBrowser.dll' or one of its dependencies. is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)"} System.BadImageFormatException: {"Could not load file or assembly 'XIBrowser.dll' or one of its dependencies. is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)"}

It appears that i can't load the project without the main application being set to Target platform of x86 which means i loose all the benefits of running it on a x64 bit OS.

So ... Is there any way around this? I don't really want to maintain two versions of my application for x86 and x64.

Does anyone have any ideas of how to run CEFSharp but still keep my AnyCPU target?

Mark G
  • 332
  • 3
  • 12
  • No workaround. You cannot load 32-bit DLLs in 64-bit processes, nor vice-versa. The bitness of all your dependencies need to match that of your application. Just target 32-bit. It is exceedingly unlikely that your WinForms application requires more than 2 GB of RAM. – Cody Gray - on strike Jul 03 '16 at 18:27
  • https://github.com/cefsharp/CefSharp/issues/1714 – amaitland Jul 03 '16 at 21:07
  • In the short term if memory is that important set the `largeaddressaware` flag on your executable and it will address `3gb` of memory. http://stackoverflow.com/questions/1346480/how-to-make-a-net-application-large-address-aware – amaitland Jul 03 '16 at 21:29

1 Answers1

0

Yes - You're all correct. No way around it.

I've now converted my Target Framework to x86 and i'm running the x86 version of CEFSharp. All working fine.

I wrapped an interface around it and dumped it into a new project, so if i ever need to run a x64 version then it'll be really easy to convert.

Thanks all.

Mark G
  • 332
  • 3
  • 12