Hello, When I am using below simple C# code to untidy my XML string, but when executing locally it is working fine, but on server I am getting below error
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
at TidyManaged.Interop.PInvoke.tidyCreate()
at TidyManaged.Document.FromString(String htmlString)
Here is my C# code, which works fine locally.
using (Document doc = Document.FromString(HTMLStr))
{
doc.OutputXml = true;
doc.OutputHtml = false;
doc.UseXmlParser = true;
doc.IndentWithTabs = true;
doc.IndentBlockElements = AutoBool.Yes;
doc.IndentAttributes = true;
doc.CleanAndRepair();
cleanXML = doc.Save();
}
How to resolve this error?
I have checked my platform Build on Visual Studio, it is selected as "Any CPU", I have deployed this code on IIS and using .NET MVC web-application.
You need to enable your web-application application pool to run 32-bit applications.
If you can login into Windows Server, then follow these steps to resolve issue.
It should solve your issue.
In Visual Studio, you may need to change build to "Platform target" -> Select "x86", instead of Any CPU (if you are using any 32-bit library)
Select Project from Solution Explorer-> Right-click on it -> Select "Properties" -> Select "Build" -> in "Platform Target" -> Select "x86" from dropdown OR check "Prefer 32 bit", if it is allowed.
If you are getting this issue, when trying to Run web-application in browser ( IIS Express), then you may need to select 64-bit IIS.
Navigate to, Tools -> Options -> Projects and Solutions -> Web Projects -> Select "Use the 64 bit version of IIS Express" and Click "Ok"
In Solution Explorer -> Right-click on it -> Select "Properties" -> Select "Build" you are using Any CPU, you might encounter this issue if the Prefer 32-bit option is checked:
Make sure you uncheck this option.
OR
If you are getting this error in .NET Core, try to download 32-bit .netcore runtime, and having your project target x86.
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly