Message Boards Message Boards

Access a function created in Mathematica in visual studio (vb.net)?

Posted 7 years ago

So, I've tried asking this question before but I always get generally waved to the .NET/Link connection, which is really not helpful at the moment. I may indeed need to use this connection, but I am very surprised no one has been able to answer such a basic question with a kind-of step-by-step answer. I have a function of one variable that I have computed in mathematica. It doesn't matter what the function is, so for simplicity it could just be called f[x_]:=Sin[x]. Now, what I want to do is to be able to call this function in a visual basic .NET program, such as:

i = 0
Do until i = 3 {
Print f[i];
i++;
loop}

Obviously, the f[i] is the function I defined in mathematica, and in this case represents Sin[x], so the vb.net program should print the results of Sin[0], Sin[1], Sin[2], and Sin[3]. The actual function is much more complex and can't really be handled by visual studio (vb.net), so I need to access the mathematica function from my vb.net program. Can anyone help answer this question? For some reason no one has been able to so far and I am puzzled by this. Thanks in advance.

POSTED BY: Patrick Cesarano
4 Replies
Posted 5 years ago

Did you ever figure this out? I am having the same issue currently. I don't think the executable is the answer but I think it is close. I think it would be better to create a dll for the Mathematica function and then reference it using Visual Studio. However, the issue that I am having is that Visual Studio really wants a C++ dll and the one that Mathematica outputs is a C dll.

POSTED BY: Jamie Dixson

The disadvantage of generating C code being that it does not work for all Mathematica code. APIs do not have this restriction. A fact that may be relevant since you mention that your function f is complex.

POSTED BY: Peter Heemeijer

Have you tried cloud-deploying an API with your function f, and then calling f within Visual Studio using the API's URL?

POSTED BY: Peter Heemeijer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract