I managed to get a .Net Standard 2.1 DLL to work by using the old-style DllExport method. However, anything except extremely basic operations would cause unhandled exceptions to be thrown - eg Debug.WriteLine inside the method - exception. Try/catch block inside the method - exception.
.Net Core 3.1, couldn't even get to load at all. I guess it's not properly supported, which is a real shame, because otherwise it would be trivially easy to throw up a proper .Net Core API hosted inside MetaTrader.
I managed to get a .Net Standard 2.1 DLL to work by using the old-style DllExport method. However, anything except extremely basic operations would cause unhandled exceptions to be thrown - eg Debug.WriteLine inside the method - exception. Try/catch block inside the method - exception.
.Net Core 3.1, couldn't even get to load at all. I guess it's not properly supported, which is a real shame, because otherwise it would be trivially easy to throw up a proper .Net Core API hosted inside MetaTrader.
Correction - .Net Standard 2.0 works fine (which I should have known, since it's the highest .Net Standard version compatible with .Net Framework)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Has anyone managed to get DLL imports working with .Net Standard or .Net Core?
I created a simple class library in .Net Framework 471 with a single, simple Add method:
I was able to import the DLL in the MQL5 code for a test indicator, reference the method with Class1::Add(2, 2), compile, attach and successfully execute the result.
For .Net Standard and/or .Net Core, all of the above steps work up until you load the indicator. Although the code compiles, and the terminal correctly finds the method in the DLL import:
when the indicator initialises (even before it's tried to execute the external method), you get an error "function 'MetaTraderApiHostStandard.Class1::Add' not found in '...\MQL5\Libraries\MetaTraderApiHostStandard.dll'" in the Experts tab.
I've tried compiling in x64 mode, as apposed to Any CPU, but didn't make any difference.
Does anyone know if .Net Standard/.Net Core are supported? Cannot find anything when searching.