Adoxio / xRM-Portals-Community-Edition

The definitive edition of Microsoft Open Source Portals, supported by the experts in portals.
MIT License
107 stars 60 forks source link

An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) #33

Closed amervitz closed 6 years ago

amervitz commented 6 years ago

An exception with the following stack trace occurs when using features that perform HTML sanitization and running the site in 32-bit mode:

An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
System.BadImageFormatException
   at SafeHtml.SafeHtmSanitizer.NativeMethods.OshFGetSafeHTMLAllocForManaged2(Byte[] rgbSrc, Int32 cbSrc, Int32 cpSrc, Byte** rgbDst, Int32& cbDst, Int32 cpDst, Int32 grfosh)
   at SafeHtml.SafeHtmSanitizer.BuildSafeHtml(String existingHtml, SafeHtmlFlags flags, String& newHtml) in C:\xRM-Portals-Community-Edition\Framework\SafeHtml\SafeHtmSanitizer.cs:line 162
   at SafeHtml.SafeHtmSanitizer.GetSafeHtml(String currentHtml, SafeHtmlFlags flags, Boolean& wasBad) in C:\xRM-Portals-Community-Edition\Framework\SafeHtml\SafeHtmSanitizer.cs:line 127
   at SafeHtml.SafeHtmSanitizer.GetSafeHtml(String currentHtml) in C:\\xRM-Portals-Community-Edition\Framework\SafeHtml\SafeHtmSanitizer.cs:line 113
...

There is a native dll included, osafehtml.dll, that is pinvoked for HTML sanitization, that is compiled in 64-bit mode and causes this exception when pinvoked in 32-bit processes.

The installation instructions do indirectly mention using the 64-bit configuration when publishing the site to an Azure web app. I've verified this error occurs with on-premise IIS hosting and in Azure.

Actions:

  1. List 64-bit as a requirement in installation instructions IIS image Azure Web App image

  2. Consider replacing HTML sanitization with a managed library, as already listed in the Update SafeHtml to use only managed code project.

amervitz commented 6 years ago

64-bit requirements handled by commit https://github.com/Adoxio/xRM-Portals-Community-Edition/commit/259cfb2a9211a176ff8a185443946bf58ecdb016.

HTML sanitization library changes will be handled separately if determined to be appropriate.