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

Add-in Express™ Support Service
That's what is more important than anything else

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
 
Justin Kloos




Posts: 6
Joined: 2015-12-03
Hello!

I’ve inherited an older project that utilizes AddinExpress that needs to be updated to .NET 4.5.2.
The project also uses AddinExpress.MAPI.

I’m receiving the following exception at runtime when attempting to access fields via AddinExpress.MAPI:
“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.”


What would be the workaround for this?

Note that I also receive this error when moving the add-in via outlook after it's installed:

Exception Source: Shugo.FileGuardian.Outlook.Addin
Exception Type: System.IO.FileLoadException
Exception 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.
Exception Target Site: AddInModule_AddinBeginShutdown

---- Stack Trace ----
ShugoFileGuardianOutlookAddin.AddInModule.AddInModule_AddinBeginShutdown(sender As Object, e As EventArgs)
Shugo.FileGuardian.Outlook.Addin.DLL: N 00000 (0x0) JIT
AddinExpress.MSO.ADXAddinModule.AddinExpress.MSO.IDTExtensibility2.OnBeginShutdown(custom As Array&)
Shugo.FileGuardian.Outlook.Addin.DLL: N 0064 (0x40) IL

(Outer Exception)
Application Domain: C:\Projects\Shugo\APP\FileGuardian.Outlook\Shugo.FileGuardian.Outlook.Addin\bin\x86\Release\
Assembly Codebase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/AddinExpress.MSO.2005/v4.0_10.1.4703.0__4416dd98f0861965/AddinExpress.MSO.2005.dll
Assembly Full Name: AddinExpress.MSO.2005, Version=10.1.4703.0, Culture=neutral, PublicKeyToken=4416dd98f0861965
Assembly Version: 10.1.4703.0

Exception Type: AddinExpress.MSO.ADXExternalException
Exception Message: An error has occurred in the code of the add-in.

---- Stack Trace ----



I'd greatly appreciate any help you can give me! Thank you very much!!
Posted 11 Jul, 2022 14:10:02 Top
Justin Kloos




Posts: 6
Joined: 2015-12-03
Note that I've attempted to add
<startup useLegacyV2RuntimeActivationPolicy="true" />
and various other tips I found in searches in the app.config
Posted 11 Jul, 2022 14:14:41 Top
Andrei Smolin


Add-in Express team


Posts: 18338
Joined: 2006-05-11
Hello Justin,

I've responded to your blog comment with this test:

AddinExpress.MAPI doesn’t support .NET 4.X. You need to replace AddinExpress.MAPI calls with equivalent calls of PropertyAccessor object. You get such an object using the PropertyAccessor property available on all Outlook item types (e.g. MailItem) as well as on some non-item classes. See https://docs.microsoft.com/en-us/office/vba/api/outlook.propertyaccessor.

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 12 Jul, 2022 03:46:12 Top
joos




Posts: 6
Joined: 2015-12-03
Thank you very much for your help, Andrei. I will refactor the code to use PropertyAccessor. Should I be referencing a certain Outlook dll from "Add-in Express for .NET\Redistributables\Interop Assemblies" if I wanted to support all versions of Outlook?


For instance, to get a recipient's first name, the following line was used:

AddInModule.CurrentInstance.MAPIStoreAccessor.GetProperty(m_recipient.AddressEntry, AddinExpress.MAPI.ADXMAPIPropertyTag._PR_GIVEN_NAME)



What dll would I reference to do the equivalent? Is there any chance you might have a code example?
Posted 13 Jul, 2022 09:11:57 Top
Andrei Smolin


Add-in Express team


Posts: 18338
Joined: 2006-05-11
Hello Joos,

Andrei Smolin writes:
Should I be referencing a certain Outlook dll from "Add-in Express for .NET\Redistributables\Interop Assemblies" if I wanted to support all versions of Outlook?


No. But PropertyAccessor is only available in Outlook 2007 and above. Also, the use of this object in Outlook 2007 may be somewhat limited.

That means, in Outlook 2003 (and may be in Outlook 2007) you will need to use Extended MAPI; I believe there are some code samples on the forums. Outlook 2010 has a 64 bit version and you'll need to use PropertyAccessor.

joos writes:
For instance, to get a recipient's first name, the following line was used:


Googling for PR_GIVEN_NAME brings you to https://docs.microsoft.com/en-us/office/client-developer/outlook/mapi/pidtaggivenname-canonical-property.

Use the Identifier value (which is a 4-hex-symbol string) from that page to construct a correct property tag (which is a 8-hex-symbol string) as described at https://docs.microsoft.com/en-us/office/client-developer/outlook/mapi/mapi-property-type-overview; you can google for a correct variant.

Use the property tag to construct the string to use with the PropertyAccessot object; see https://docs.microsoft.com/en-us/office/vba/outlook/how-to/navigation/referencing-properties-by-namespace.

I suppose it is possible to use Outlook Spy to get the property tag faster.

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 13 Jul, 2022 13:17:08 Top