0 votes

When trying to use the MailBrowserControl in a VB.Net project (with Visual Studio 2017) I am getting the following errors and the program aborts when trying to open a form with the MailBrowserControl on the form.

There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "ProtocolEx, Version=1.0.4621.33152, Culture=neutral, PublicKeyToken=6dc438ab78a525b3, processorArchitecture=AMD64", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.

There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "MailBrowserControl, Version=3.0.17241.1703, Culture=neutral, PublicKeyToken=6dc438ab78a525b3, processorArchitecture=AMD64", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.

References:
C:\Program Files\Limilabs\Mail\Redistributables\Net45\MailBrowserControl\x86\MailBrowserControl.dll
C:\Program Files\Limilabs\Mail\Redistributables\Net45\MailBrowserControl\x86\Protocol.dll

Mail.dll itself works fine.

Regards,

Kevin Ball

by

1 Answer

0 votes

Please double check your references. For 64 bit projects you need to reference ProtocolEx and MailBrowser from x64 folder. For 32 bit projects you need to reference both from x86 folder.

(Please note that Visual Studio designer runs as 32 bit application)

by (301k points)
Thank you for your prompt response.

Unfortunately neither option works with Visual Studio.

There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "ProtocolEx, Version=1.0.4621.33152, Culture=neutral, PublicKeyToken=6dc438ab78a525b3, processorArchitecture=AMD64", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.   

Severity    Code    Description    Project    File    Line    Suppression State
Warning        There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "MailBrowserControl, Version=3.0.17241.1703, Culture=neutral, PublicKeyToken=6dc438ab78a525b3, processorArchitecture=AMD64", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.

Regards,

Kevin Ball
What kind of project is that?
I went into the Project configuration and changed the target from Any CPU to specifically x86 and then re-referenced the x86 control. It loaded and compiled OK but when I opened the form with the control I got this runtime error.

System.IO.FileLoadException occurred
  HResult=0x80131621
  Message=Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.
  Source=ChaseAlpha
  StackTrace:
   at ChaseAlpha.FormEmail.cmdRefresh_Click(Object sender, EventArgs e) in C:\Users\kevin\Documents\Visual Studio 2017\Projects\ChaseAlpha\ChaseAlpha\FormEmail.vb:line 32
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at ChaseAlpha.Main.main() in C:\Users\kevin\Documents\Visual Studio 2017\Projects\ChaseAlpha\ChaseAlpha\Main.vb:line 25
I also tried the other way, i.e. choosing a target of an x64 project, re-referencing the x64 controls. I added the control to the form programmatically rather than through the designer.

I got a similar runtime error:
System.IO.FileLoadException occurred
  HResult=0x80131621
  Message=Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.
  Source=ChaseAlpha
  StackTrace:
   at ChaseAlpha.FormEmail.cmdRefresh_Click(Object sender, EventArgs e) in C:\Users\kevin\Documents\Visual Studio 2017\Projects\ChaseAlpha\ChaseAlpha\FormEmail.vb:line 33
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at ChaseAlpha.Main.main() in C:\Users\kevin\Documents\Visual Studio 2017\Projects\ChaseAlpha\ChaseAlpha\Main.vb:line 25
In order to use a CLR 2.0 mixed mode assembly, you need to modify your App.Config file to include:

<?xml version="1.0"?>
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>
So are the assemblies in your net45 redistributable folder not Net 4.5 assemblies?
ProtocolEx is not a .NET assembly. It's managed C++
It is still confusing that you provide a net45 redistributable folder which contains non Net 4.5 compatible items.
Can you not provide a library which is fully Net 4.5 compatible?
Will this configuration modification have any implications on my ability to use Net 4.5 functionality in my application?
ProtocolEx is a managed C++ assembly it is compatible with .NET 4.5.
With respect, according to the error message the dot net runtime seems to think the Mixed mode assembly is built against  a significantly earlier version of the runtime.
It would help if the need for this additional configuration was identified up front in your documentation, particularly as anyone developing now in dot net will run across this problem, if they use the MailBrowserControl.
...