As far as I understand, the RGiesecke UnmanagedExportLibrary template uses comments like // Code for parsing IL files in some places. Russian-speaking Windows-ers insert there Russian comments like // Size, and that's why his template doesn't work. There are simply no functions in the DLL and that's why error 127 is thrown. It's a pity, for the sake of only this template I don't want to change the Windows interface language, though it works quite well and seems to be correct, at least DLLs are at least unloaded. Microsoft is also a broom, you can easily transfer data from C++ to C#, but the other way round is a big problem.
A set of compile-time libraries (nothing to deploy) and a build task that enable you to export functions from managed code to native applications. That means, you can create plugins in a managed language like C# or F# for native applications that only have a C-Api (like Notepad++). The nuget package is all you need. Just mark your methods with [DllExport] and build for x86, x64 or ia64. Hints: - You have to set your platform target to either x86, ia64 or x64. AnyCPU assemblies cannot export functions. - The export name defaults to the method name and the calling convention to stdcall. If that's all what you want, you can just use [DllExport] without parameters. - You cannot put your exports in generic types or export generic methods. (The CLR wouldn't know what type parameters to use)
In comparison to the question above i need to combine DLLs so that final mixed DLL could export their functions to other unmanaged applications. For this i would like to compile them both as .netmodule and then combine them into one file with a linker so i have : 1) Libs - project with some library in C# - it does not have any dependencies...
I also provided several examples on how to marshal MQL5 structures against C# and how to invoke exported DLL functions in MQL5 scripts. - Page 2 - Category: articles, library comments
Yes, in some time we will write a new article about using DLLs. A lot of interesting things have been added there.
In the meantime, you can use the examples from the article under discussion. There is nothing complicated there.
And ... How long to wait? A year, two... or 10?
It's been 3 years already. According to the article mentioned in the very beginning it is not possible to import methods from dll. Where are the examples?
Thank you very much for this article. I've used the ideas here to build this opensource MQL library for C#.
https://github.com/jseparovic/MQL4CSharp
It's still under development and is untested at present, but initial tests show the idea works.
It's very basic in how it sends commands from C#, using a Thread for the C# code to run in, and getters/setters for communication. MQL polls for waiting commands every millisecond, while the C# code can block until the result is written.
Take a look at https://github.com/jseparovic/MQL4CSharp/blob/master/MQL4CSharp/UserDefined/Strategy/MaCrossStrategy.cs for an example of how to implement a strategy in c#.
I'm on a 64 win 8.
I compiled it with vs2013.
However, it loads, but there is an unresolved import function call.
How can I solve this?
2014.03.05 20:39:59.220 UnmanagedExportsDLLExample1 (XAUUSD,H1) unresolved import function call
2014.03.05 20:39:59.220 UnmanagedExportsDLLExample1 (XAUUSD,H1) Cannot find 'Add' in 'Testme.dll'
2011.10.29 20:13:37 2000.01.03 00:00 Expert_NN_1_1 USDJPY,H1: cannot call function 'sum' from dll 'NN 1 DLL.dll' (error 127)
Hi,
Am getting similar errors. How did you sort it out?...
2014.03.28 22:16:41.199 2014.03.25 23:59 unresolved import function call
2014.03.28 22:16:41.199 2014.03.25 23:59 Cannot find 'Set2DArray' in 'Testme.dll'
As far as I understand the RGiesecke UnmanagedExportLibrary template...
This message was left over half a year ago. Has anything changed since then????
Method one:
I have 64 win 7, vs2012 C#. Downloaded the owner's testme.zip template file.
In the middle of the prompt a few errors (wrong path, missing files, etc. and so on and so forth), has been solved.
But in the end, still appear and and upstairs the same problem. I do not know if it is solved now? What method to solve.
Method two:
NuGet installed RGiesecke package.
https://www.nuget.org/packages/UnmanagedExports/1.2.6
The latest version from 201311 prompts
Error 2 C:\Users\Administrator\AppData\Local\Temp\tmp8B24\dllTest.il(58) : error : syntax error at token '{ ' in: {
dllTest
You can use C++ stripper with the help of IJW, and then merge everything into one single DLL purely by means of compiler - linker, perversions with the template described in the article are not necessary, described briefly here - http://stackoverflow.com/questions/26226958/include-managed-c-sharp-dll-into-unmanaged-c-dll-all-in-one-single-file.
Well, and the described method with the template RGiesecke - it is a hack and such sooner or later stops working, I, by the way, also did not work ...But if someone still wants to play with IL method described in the article, there is one more bike, but it doesn't work either - https://github.com/winch/winch.pinkbile.com-c-sharp/tree/master/dll_tool/dll_tool.
Hello,
Was anybody able to send a structure with string variables inside, to the dll?
I was able to send int, double, float, but for string variables i get this error:
Access violation read to 0x0000007BHere is my C# structure:
And here its the mql4 structure:
I have tryed to marshal the string variable inside the structure but MT4 crashes totaly, no error just hangs and crushes in windows.
Thank you.
Yes, in some time we will write a new article about using DLLs. A lot of interesting things have been added there.
In the meantime, you can use the examples from the article under discussion. There is nothing complicated there.
And ... How long to wait? A year, two... or 10?
It's been 3 years already. According to the article mentioned in the very beginning it is not possible to import methods from dll. Where are the examples?
Thank you very much for this article. I've used the ideas here to build this opensource MQL library for C#.
https://github.com/jseparovic/MQL4CSharp
It's still under development and is untested at present, but initial tests show the idea works.
It's very basic in how it sends commands from C#, using a Thread for the C# code to run in, and getters/setters for communication. MQL polls for waiting commands every millisecond, while the C# code can block until the result is written.
Take a look at https://github.com/jseparovic/MQL4CSharp/blob/master/MQL4CSharp/UserDefined/Strategy/MaCrossStrategy.cs for an example of how to implement a strategy in c#.
Cheers,
Jason