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

**URL:** <https://community.wolfram.com/t/access-a-function-created-in-mathematica-in-visual-studio-vb-net/9900>\
**Category:** Questions\
**Tags:** computer-science, software-development, interface-construction\
**Created:** [January 18, 2017, 5:58pm UTC](https://community.wolfram.com/t/access-a-function-created-in-mathematica-in-visual-studio-vb-net/9900 "2017-01-18T17:58:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![patrickcesarano](https://avatars.discourse-cdn.com/v4/letter/p/97f17d/32.png) [@patrickcesarano](https://community.wolfram.com/u/patrickcesarano)\
**Post date:** [January 18, 2017, 5:58pm UTC](https://community.wolfram.com/t/access-a-function-created-in-mathematica-in-visual-studio-vb-net/9900/1 "2017-01-18T17:58:41Z")

</div>

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](http://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](http://vb.net)), so I need to access the mathematica function from my [vb.net](http://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.

---

<div class="post-metadata">

**Author:** ![pheemeijer](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/pheemeijer/32/16965_2.png) [@pheemeijer](https://community.wolfram.com/u/pheemeijer)\
**Post date:** [January 21, 2017, 1:57pm UTC](https://community.wolfram.com/t/access-a-function-created-in-mathematica-in-visual-studio-vb-net/9900/2 "2017-01-21T13:57:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fkampas](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/fkampas/32/41217_2.png) [@fkampas](https://community.wolfram.com/u/fkampas)\
**Post date:** [January 21, 2017, 3:22pm UTC](https://community.wolfram.com/t/access-a-function-created-in-mathematica-in-visual-studio-vb-net/9900/3 "2017-01-21T15:22:30Z")

</div>

Perhaps this will help

> **[Create Standalone Executables Using Compiled Functions: New in Mathematica 8](https://www.wolfram.com/mathematica/new-in-8/integrated-c-workflow/create-standalone-executables-using-compiled-funct.html)**

---

<div class="post-metadata">

**Author:** ![pheemeijer](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/pheemeijer/32/16965_2.png) [@pheemeijer](https://community.wolfram.com/u/pheemeijer)\
**Post date:** [January 22, 2017, 7:06pm UTC](https://community.wolfram.com/t/access-a-function-created-in-mathematica-in-visual-studio-vb-net/9900/4 "2017-01-22T19:06:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jamiedixson](https://avatars.discourse-cdn.com/v4/letter/j/34f0e0/32.png) [@jamiedixson](https://community.wolfram.com/u/jamiedixson)\
**Post date:** [November 13, 2018, 12:13am UTC](https://community.wolfram.com/t/access-a-function-created-in-mathematica-in-visual-studio-vb-net/9900/5 "2018-11-13T00:13:20Z")

</div>

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.
