-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Unable to use 'libjulia.dll' in a C# application on Windows 8.1 #8931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
What OS? I've tested the same code under Windows 7 and it worked fine. However, another user reported such an access violation on Windows 8.1. |
Windows 8.1, not tested on any other platform. |
What's confusing is that the interactive shell has no such problems, even on windows 8. What is my program doing that the interactive shell is doing differently? It's just two lines of code. |
p/invoke'ing unmanaged code is quite different from running the interactive shell. It is entirely possible that there is some weird DLL interaction - this wouldn't be the first time. However, a very quick google suggested that people have seen these violations with p/invoke'd code due to corrupt .NET installations when the system has been upgraded from Win7->8. If that is the history of your computer, you could consider updating or reinstalling the .NET SDK. I'm not sure if any of the active developers have access to Win8/8.1 (I don't) so we will likely have to rely on detailed debugging feedback from you (and patches are very much encouraged!). A first step would be to run the code under the Visual Studio debugger and see if you can step in to |
I've dabbled in C before, but not nearly enough to even know how to attach a debugger to this thing and figure out why the code crashes. By the way, Microsoft offers pre-built virtual machines and evaluation licenses of every major version of their operating system, including Windows 8. See: https://www.modern.ie/en-us/virtualization-tools#downloads The offer is meant for web developers, but it doesn't seem like the license is restricted to web development. |
I have Windows 2012 R2 in a packer VM that I can try this on, but my knowledge of .NET is almost nonexistent. I think I can get VS 2012 express installed command-line via chocolatey. Is there a command-line way to compile the C# example? I'm not sure if the VS IDE will be usable enough under a VM. |
also possible that the stack of your .NET application is too small. default is 1MB, recommended is 8MB (the linux default). you need at least a 3MB stack to build julia. |
I'm targeting the precompiled binaries in my |
@StevenLiekens do you mean the libjulia source code? Yes you can (or, should be able to... I hope) compile it from source with MSVC, see #7761, but it's pretty hacky, experimental, not first-class or documented yet, and many things in Julia are broken due to limitations of MSVC. If you want to help improve these matters that'd be awesome. |
Still poking around with this. The call to Almost forgot to mention that this behavior is for a .2.x release (just because). I'll go try a 0.3.x release now. Update: the same 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)
{
// Pass
jl_init(@"C:\Users\steven liekens.BRAIN2\AppData\Local\julia-e44b593905\bin");
// Crash
jl_eval_string("print(sqrt(2.0))");
}
} |
Have you tried telling .NET to use a larger stack (see @vtjnash comment above)? Unfortunately I don't know how to do this, so I can't help much further. |
|
this code works fine on 0.4 with x86 windows 8.1. Note the change in calling convention attribute; before that change, I had a
But in any case as I can't reproduce and there has been no update, I will close. Please comment if this is still an issue and we will reopen. |
I am not able to initialize Julialib.dll using Julia-0.4.7 (64-Bit) from C# .net (Framework v4.6) We explicitly require 64 bit of julia to do our work Please let me know if anyone has a solution. |
The Discourse forum is a better place for getting help on usage questions. It'll be easier to answer your question over there, where there are better controls for message formatting and threading. |
This works for me:
|
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:
When executed, it throws an AccessViolationException, which I believe is the .NET equivalent of a segfault.
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
The text was updated successfully, but these errors were encountered: