Calling class and methods from C# dll

6 Ansichten (letzte 30 Tage)
Kiruthika
Kiruthika am 15 Mai 2025
Bearbeitet: Ronit am 11 Jun. 2025
I'm trying to call the method from matlab, but getting error as 'Too many input arguments'.
My matlab code is
pulsar = PulsarWebClientLibrary.Pulsar("http://svt_neldah/api/");
pulsar.Client.SendCommand1(PulsarWebClientLibrary.PulsarCommands.Poke, DLDetailsEvent);
My 2 C# codes is
namespace PulsarWebClientLibrary
{ public class Pulsar : IPulsar, IDisposable
{ internal static string url;
protected internal Client pulsarClient;
public Pulsar(string url1)
{
url = url1;
Client = new Client(url);
}
}
using PulsarWebClientLibrary;
public class Client
{
public async Task SendCommand1(string command, EventHandler<object> eventHandler, string parameter = "")
{
Progress<object> progress = new Progress<object>();
progress.ProgressChanged += eventHandler;
Task t = GetAsync(command, progress, parameter);
await t;
return;
}
}

Antworten (1)

Ronit
Ronit am 11 Jun. 2025
Bearbeitet: Ronit am 11 Jun. 2025
Hello @Kiruthika,
The issue you are encountering is due to how MATLAB handles .NET interop, especially with methods that have default parameters. The issue is that MATLAB does not support default parameters when calling .NET methods. Default parameters in C# are resolved at compile-time, but MATLAB requires you to explicitly provide all parameters when invoking the method.
You need to pass all three parameters explicitly when calling the method from MATLAB, even if you are using the default value for parameter:
pulsar.Client.SendCommand1(PulsarWebClientLibrary.PulsarCommands.Poke, DLDetailsEvent, "");
I hope this helps resolves your query.
Thanks!

Kategorien

Mehr zu Debugging and Analysis finden Sie in Help Center und File Exchange

Produkte


Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by