Calling class and methods from C# dll
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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;
}
}
0 Kommentare
Antworten (1)
Ronit
am 11 Jun. 2025
Bearbeitet: Ronit
am 11 Jun. 2025
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!
0 Kommentare
Siehe auch
Kategorien
Mehr zu Debugging and Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!