F sharp - Leer dll c++ nativo con interfaz F#

<<>>
 
Vista:
sin imagen de perfil
Val: 23
Ha mantenido su posición en F sharp (en relación al último mes)
Gráfica de F sharp

Leer dll c++ nativo con interfaz F#

Publicado por Meta (12 intervenciones) el 18/06/2020 12:06:49
Buenas gente:

Tengo un programa hecho en C# y me lee una dll externo. Aquí dejo un ejemplo en C#.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Runtime.InteropServices;
 
namespace Consola_cs
{
    class Program
    {
        static void Main(string[] args)
        {
            // Título de la ventana.
            Console.Title = "Consola C# 2019";
 
            // Tamaño de la ventana.
            Console.SetWindowSize(40, 5);
 
            // Color de las letras.
            Console.ForegroundColor = ConsoleColor.Green;
 
            Console.WriteLine(Marshal.PtrToStringAuto(SUPER_DLL.Mensaje()));
            Console.WriteLine(SUPER_DLL.Suma(1764, -764).ToString());
 
            // Pulse cualquier tecla para salir.
            Console.ReadKey();
        }
        internal class SUPER_DLL
        {
            [DllImport("Super_dll.dll")]
            extern static public int Suma(int a, int b);
            [DllImport("Super_dll.dll")]
            extern static public IntPtr Mensaje();
        }
    }
}

Lo he intentado hacer lo mismo con el leguaje F# y no me funciona.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
open System
open System.Runtime.InteropServices
 
module Program = let [<EntryPoint>] main _ = 0
 
module InteropWithNative = let
    [DllImport("Super_dll.dll")]
    extern static public int Suma(int a, int b)
 
    [DllImport("Super_dll.dll")]
    extern static public IntPtr Mensaje()
 
    // Título de la ventana.
    Console.Title <- "Consola F# 2019";
 
    // Tamaño de la ventana.
    Console.SetWindowSize(40, 5)
 
    // Color de las letras.
    Console.ForegroundColor <- ConsoleColor.Blue
 
    Console.WriteLine(Marshal.PtrToStringAuto(SUPER_DLL.Mensaje()))
    Console.WriteLine(SUPER_DLL.Suma(1764, -764).ToString())
 
    // Pulse cualquier tecla para salir.
    Console.ReadKey()

¿Alguna idea?

Que tengan buena salud.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder