.Net version and Visual Studio settings for developing with Studio 2015 API

Hi,

I'm developing an application using the 2015 API (Project automation and Translation memory).
I'm using Visual Studio 2012 and have set the target .Net framework in the project to 4.5.2.
I have Studio 2015 with latest updates, and building to the c:\Program Files (x86)\SDL\SDL Trados Studio\Studio4\ folder.

When the application reaches this line:
FileBasedTranslationMemory tm = new FileBasedTranslationMemory(
tmPath,
"",
CultureInfo.GetCultureInfo(source),
CultureInfo.GetCultureInfo(target),
this.GetFuzzyIndexes(),
this.GetRecognizers(),
TokenizerFlags.DefaultFlags,
WordCountFlags.DefaultFlags);

I get an exception:
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.

I can fix this, setting the useLegacyV2RuntimeActivationPolicy attribute to true in my app.config, but that raises a different exception on line:
FileBasedProject studioProject = new FileBasedProject(projectInfo, templateReference);

Exception:
A call to PInvoke function 'SentinelRMSCore!SentinelRMSCore.Interface.LSAPI::VLSsetFileName' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

Thank you for your help.