locked
[WPF] Using WindowsFormsHost RRS feed

  • Question

  • Hey guys,

    So I got MapWinGIS, which is intended for WinForms, and I am currently trying to use it in WPF using WindowsFormsHost.

    I followed the Microsoft docs tutorial (https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/walkthrough-hosting-an-activex-control-in-wpf), yet when I try to run the project I got an exception...

    An unhandled exception of type 'System.IO.FileNotFoundException' occurred in System.Windows.Forms.dll
    The specified module could not be found. (Exception from HRESULT: 0x8007007E)

    I do not know what module is missing. Every required module is referenced and added.
    I should note I did get this project to work in the first place in WinForms.

    I also asked this question on the MapWinGIS forum (https://mapwindow.discourse.group/t/getting-mapwingis-to-work-in-wpf/664), but so far they have not found any solution either. I am hoping someone here knows how to fix this.

    Thanks very much!

    Saturday, July 25, 2020 7:56 AM

Answers

  • Did you check if your Forms application works in both of 32- and 64-bit project configurations? (Or using different “Prefer 32-bit” option).

    Try setting the same options in WPF, and also the same .NET Framework.


    • Edited by Viorel_MVP Saturday, July 25, 2020 10:20 AM
    • Marked as answer by ZeroByter Saturday, July 25, 2020 10:37 AM
    Saturday, July 25, 2020 10:18 AM

All replies

  • Did you check if your Forms application works in both of 32- and 64-bit project configurations? (Or using different “Prefer 32-bit” option).

    Try setting the same options in WPF, and also the same .NET Framework.


    • Edited by Viorel_MVP Saturday, July 25, 2020 10:20 AM
    • Marked as answer by ZeroByter Saturday, July 25, 2020 10:37 AM
    Saturday, July 25, 2020 10:18 AM
  • Thanks for your comment! You helped solve my issue.

    I knew that both projects had to be the same CPU configuration, obviously, however my mistake was when I selected at the top toolbar 'x86' I thought it would also apply to the current project (both my WinForms and WPF projects were in the same solution) but it didn't, instead it only applied to the WinForms one while the WPF one was still in 'Any CPU' (despite the toolbar doing a bit of misleading) and thus the exception crash.

    I made sure this time that both projects were using the same configuration via the configuration manager and now it works nicely, thanks!

    Saturday, July 25, 2020 10:37 AM