14

I have created a basic class that adds two numbers in c#. I have built it into a dll but when attempting to call it in golang I am unsuccessful.

Is this possible currently in golang? If so can someone provide a example how to do this?

Edit: I have included the last attempt I made at doing this. The C# dll is simply a method that adds the two numbers that are passed in.

package main

import (
    "fmt"
    "syscall"
)

func main() {
    var mod = syscall.NewLazyDLL("MathForGo.dll")
    var proc = mod.NewProc("Add");
    proc.Call(2,3);
    fmt.Printf("%v",proc)
}
Rahul Neekhra
  • 780
  • 1
  • 9
  • 39
165plo
  • 713
  • 1
  • 8
  • 20
  • How are you trying to do this? Can you please show us some code? – rhughes Oct 24 '15 at 05:53
  • I have added the last attempt I made. This version is causing a error when attempting to call go install with _undefined: syscall.NewLazyDLL_ – 165plo Oct 24 '15 at 06:12

1 Answers1

11

There is a project on Github that aims to do this.

https://github.com/matiasinsaurralde/go-dotnet

C# assemblies are not the same as C or C++ and will not load using syscall like we might want.

ptpaterson
  • 9,131
  • 4
  • 26
  • 40