Calling class and methods from C# dll
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Ronit
il 11 Giu 2025
Modificato: Ronit
il 11 Giu 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 Commenti
Vedere anche
Categorie
Scopri di più su Debugging and Analysis in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!