I am looking for a simple C# example implementing a typesafe interface to a complied MATLAB DLL using R2017b Compiler and VS2017

1 view (last 30 days)
I used the R2017b MATLAB compiler to build and install built AddMaster.DLL. No problems on this part.
function y = addOne(x)
y = x + 1;
end
Below is my (weak) attempt a a C# program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// using System.ServiceModel;
using AddMaster;
namespace LKTypeSafe
{
public interface IAddOne
{
int AddOne(int x);
}
class AddOneCls2 : IAddOne
{
public int AddOne(int x)
{
IAddOne obj = new AddMaster.addOne(int x);
int two = 0;
return two = obj.AddOne(x);
}
}
class AddMaster
{
static void Main(string[] args)
{
Console.WriteLine("Starting LKTypeSafe");
AddOneCls obj = null;
int input = 0;
try
{
// Instantiate your component class.
obj = new AddOneCls2();
// Invoke your component.
int output = obj.addOne(input);
// print the output.
Console.WriteLine(output);
Console.Write("\nPress any key to exit...");
Console.ReadKey(true);
}
catch
{
throw;
}
}
}
}
Step by step help on using VS2017 to build this simple example is requested. Any Help is appreciated.

Answers (0)

Categories

Find more on C Shared Library Integration in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by