.netlink - Problem with inserting a picture into Excel sheet in NETLink way

I'm using the NETLink to work with Excel object, there be differences to write code according to the NETLink user manual in Mathematica from C#, but it's hard to do more in fact.I wanted to put a picture in Excel ActiveSheet, the MSDN gvies notation like this in C#:public Microsoft.Office.Interop.Excel.Picture Insert (string Filename, object Converter);first time I trans it asactivesheet@Cells[20, 1]@Select[]activesheet@Pictures@Insert["E:\\birds.png"]error ocurred. ... at last, the code was changed to activesheet@Cells[20, 1]@Select[] activ...Read more

.netlink - Command to get License Management Monitor info

Using Netlink, when we have more users than Mathematica licenses (used in a pool), we get messages such as: Error code: 11. Connected MathLink program has closed the link, but there might still be data underway, that I translate into a more user friendly message.There's a Wolfram License Management Monitor on a server and it generates these reports:Ref: http://uczelnia.mazovia.edu.pl/info/mathematica.htmlUnfortunately the License Server is locked down (its still in the network unlike this: How to access Mathematica license server (being outsi...Read more

.netlink - How can I copy a figure to the clipboard in SVG?

I frequently include plots in my emails. The easiest and most reliable way I have found is to just capture a part of the screen using greenshot (Windows) and paste into the message.Microsoft recently added SVG support to Office 2016 including Outlook. Hence, it should be possible to embed a nice resolution independent SVG plot created in Mathematica into an Outlook message.Mathematica doesn't have a "Copy as SVG" menu option. But you can Export to a file, and then import it into you message, however, this is a lot of clicks.So the question is: ...Read more

.netlink - How to create .NET "System.Windows.Clipboard"?

I have followed the instructions for creating a blank .Net form and it works. Needs["NETLink`"]InstallNET[];myform = NETNew["System.Windows.Forms.Form"];ShowNETWindow[myform];(* Don't forget to release it later *)ReleaseNETObject[myform];However, I cannot get a reference to "System.Windows.Clipboard".clipboard = NETNew["System.Windows.Clipboard"] NET::netexcptn: A .NET exception occurred: System.TypeLoadException: Type System.Windows.Clipboard not found. at Wolfram.NETLink.TypeLoader.GetType(String typeName, String assemblyName, Boolean th...Read more

.netlink - How to make a get image by a NETObject

This more then a .net question but I'm in Mathematica using.Suppose I want to get a image from my clipboard,so I make a function like following.If there is a image in your clipboard then you run this code.You will get a image NETObject:Needs["NETLink`"]InstallNET[];LoadNETType["System.Windows.Forms.Clipboard", StaticsVisible -> True];img=GetImage[](*« NETObject[System.Drawing.Bitmap]»*)How to make the img be a image?There is a related post:Clipboard withtransparencyBut his image from a Mathemtica expresssion....Read more

.netlink - Using .NET 4.0 from NETLink

Using Mathematica 8, I can check the version of the .NET framework used by NETLink as follows:Needs["NETLink`"]InstallNet[];LoadNETType["System.Environment"];System`Environment`Version@ToString[] "2.0.50727.5448"As you can see, it is the old 2.0 framework. However, my machine has version 4.0 of the .NET framework installed. Is there a way to configure Mathematica to use the newer version?...Read more

Aborting a computation correctly in .NETLink to allow future computations

Has anyone had any success using the AbortEvaluation() function in IKernelLink to stop a computation and then do more computation and retrieve results?I've managed to find the jlink sample and some description on how to set it up; PutEvaluate and WaitForAnswer() on one thread, and call AbortEvaluation() from another. The following is a sample code that I'm written according to the description: var mlink = MathLinkFactory.CreateKernelLink(); var t = Task.Factory.StartNew( () => { mlink.Evalua...Read more

.netlink - Using a pointer in NETLink

I am trying to use NETLink to control a camera exposure in our experiment. I have successfully connected to the camera and taken images. However, downloading it off the camera is trickier. The code that works in C# looks like this.//Expose for image and wait for triggeringApogeeCamera.Expose(0.1, true);do { } while (ApogeeCamera.ImagingStatus != Apn_Status.Apn_Status_ImageReady);//Download image from cameraushort[] pixels = new ushort[width * height];unsafe{ fixed (ushort* ptr = pixels) { int ptrValue = (int)ptr; ApogeeCamer...Read more

.netlink - Problem with .NET/Link - Unable to load DLL 'ml32i4.dll'

I have programmed this example for the last 6 years with various versions of Mathematica and .NET. This year I have moved to Version 10.0.2 and it doesn't work. I am using Visual Studio 12 for C#. My C# code is unremarkable:string[] mlArgs = { "-linkmode", "launch", "-linkname", @"C:\Program Files\Wolfram Research\Mathematica\10.0\SystemFiles\Kernel\Binaries\Windows-x86-64\MathKernel.exe" }; IKernelLink ml = null; try { ml = MathLinkFactory.CreateKernelLink(mlArgs); ml.WaitAndDiscar...Read more

.netlink - Replacing lambda expressions in LINQ queries through NET/Link

We have an IEnumerable Objects in C# that we want to import into the Wolfram Financial Platform. In the current C# API, we use LINQ queries to select from the Objects the specific Object that we need. In Wolfram Financial Platform we can import the IEnumerable Objects through NET/Link (More info: http://reference.wolfram.com/language/NETLink/tutorial/Overview.html)Once the object is imported, there does not seem to be a way to use LINQ queries even after importing the LINQ library. Additionally, lambda expressions used in the LINQ queries do no...Read more

.netlink - NETLink System.AccessViolationException when compiling #C with .NET 4.0 or higher

I have a program, which used NETlink to call Mathematica functions from C#. When we compile this program with .NET 4.0 or higher we get "An unhandled exception of type 'System.AccessViolationException' occurred in Wolfram.NETLink.dll"And trace here: System.AccessViolationException was unhandled HResult=-2147467261 Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Source=Wolfram.NETLink StackTrace: at Wolfram.NETLink.Internal.Win64MathLinkAPIProvider.MLNextPacket(I...Read more

.netlink - NETLink Problem with C# DLL

I am not getting the answers back from my DLL calls. Here are the simple C# functions. Not sure why I am not getting the correct answers. I can DLL import kernel32d.dll and can call getTickCount() just fine. Just not my home grown DLL. Any insight would be appreciated.Thanks,Philusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace wpa1{ public class Class1 { public string func1(string strIn) { System.Console.WriteLine(strIn); char[...Read more

.netlink - How to convert an array in C# .net to ListPoint for calling ListPointPlot3D?

I have a two-dimensional array in C# (using .Netlink)double[][] rhoThe values of the array change dynamically as it represents some process in time. I have tested the following code to make sure 3D Graphics will work normally:try { MathKernel k = new MathKernel(ml); k.CaptureGraphics = true; k.GraphicsFormat = "JPEG"; string command = @"Show[ListPointPlot3D[Table[Sin[j^2 + i], {i, 0, 3, 0.1}, {j, 0, 3, 0.1}]]]"; k.Compute(command); pictureBox1.Image = k.Graphics[0]; } ...Read more

.netlink - Access to Read[] method on .Net object incorrectly flagged as syntax error, and changes needed to call NETLink functionality in a package.

Mathematica can access .net objects easily via NETLink. Works well to custom assemblies. However, I have run into a problem when trying to use Read() method on a SqlCeResultSet object returned by System.Data.SqlServerCe.dll.Read() method is documented here for MS SQL Compact Edition (v3.5 SP2)https://msdn.microsoft.com/en-us/library/system.data.sqlserverce.sqlcedatareader.read(v=vs.100).aspxBelow a simple script to demonstrate the problem. You will notice that in the function GetAllGuids[] the .nb editor will place a red carat on the results@Re...Read more