-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Description
The documentation gave me the impression that I can use .NET P/Invokes to run Julia scripts in a .NET environment. I tried porting the embedding.c program to C#, but I always get one or more errors.
My code:
using System.Runtime.InteropServices;
class Program
{
[DllImport("libjulia.dll")]
public static extern void jl_init(string julia_home_dir);
[DllImport("libjulia.dll")]
public static extern void jl_eval_string(string str);
static void Main(string[] args)
{
jl_init(null);
jl_eval_string("print(sqrt(2.0))");
}
}When executed, it throws an AccessViolationException, which I believe is the .NET equivalent of a segfault.
.\Program.exe
Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x5a6e35f324 -- unknown function (ip: 1849029412)
unknown function (ip: 1849029412)
abstract_call_gf at inference.jl:622
unknown function (ip: 1840590556)
abstract_call at inference.jl:835
unknown function (ip: 1840590556)
abstract_eval_call at inference.jl:927
abstract_eval at inference.jl:952
unknown function (ip: 1840590556)
abstract_interpret at inference.jl:1115
unknown function (ip: 1840590556)
typeinf at inference.jl:1436
at (unknown line)
unknown function (ip: 1840590556)
typeinf_ext at inference.jl:1236
unknown function (ip: 1840590556)
unknown function (ip: 1840586610)
unknown function (ip: 1840588250)
unknown function (ip: 1840590657)
unknown function (ip: 1840641231)
unknown function (ip: 1840890118)
unknown function (ip: 1840863696)
unknown function (ip: 1840926177)
unknown function (ip: -1234565522)
unknown function (ip: -1235658528)
unknown function (ip: -1104811560)
unknown function (ip: -1104811200)
unknown function (ip: -1104811384)
unknown function (ip: -1104812144)
unknown function (ip: 1)
unknown function (ip: -879819355)
unknown function (ip: 373044544)
unknown function (ip: -1104811200)
unknown function (ip: -1235658528)
unknown function (ip: -1235658528)
unknown function (ip: -1104812144)
unknown function (ip: -1234565522)
unknown function (ip: -1104812112)
unknown function (ip: -1235658528)
unknown function (ip: -879819355)
unknown function (ip: -1102667552)
unknown function (ip: 1840926111)Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x5a6e35f324 -- unknown function (ip: 1849029412)
unknown function (ip: 1840926112)Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x5a6e35f324 -- unknown function (ip: 1849029412)
unknown function (ip: 1840926112)Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x5a6e35f324 -- unknown function (ip: 1849029412)
unknown function (ip: 1840926112)Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x5a6e35f324 -- unknown function (ip: 1849029412)
unknown function (ip: 1840926112)Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x5a6e35f324 -- unknown function (ip: 1849029412)
unknown function (ip: 1840926112)Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x5a6e35f324 -- unknown function (ip: 1849029412)
unknown function (ip: 1840926112)Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Brain2.Julia.Console.Program.jl_init(String julia_home_dir)
at Brain2.Julia.Console.Program.Main(String[] args)
I'm using Visual Studio 2012 and .NET 4.5
Tested with v0.3.2 (Current Release) for both x86 and x64 and also with v0.4.0-dev-7a7110b-win64
Julia Version 0.4.0-dev+1318
Commit 7a7110b* (2014-10-27 03:52 UTC)
Platform Info:
System: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i7-4700MQ CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas
LIBM: libopenlibm
LLVM: libLLVM-3.3