NuGet - mathworks.prodserver.dotnetclient library
19 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi All,
Curious to understand if any of you are using:
aka: mathworks.prodserver.dotnetclient / the {MATLAB PRODUCTION SERVER DOTNET CLIENT} released few months back ... and what's the feedback on it, as I keep hitting some
System.InvalidCastException: Unable to cast object of type '...+MySqrtInterfaceProxy' to type 'MySqrtInterface', for an interface definition:
public interface MySqrtInterface
{
double mySqrt(double in1);
}
and
client = new MWHttpClient();
then:
which throws following InvalidCastException (+MySqrtInterfaceProxy' to type 'MySqrtInterface'):
System.InvalidCastException: Unable to cast object of type '...._+MySqrtInterfaceProxy' to type 'MySqrtInterface'.
A curl would successfully return a meaningful result, proving the Production Server Compiler is running great in Test mode:
curl -v http://localhost:9911/lib/mySqrt -H "Content-Type: application/json" -d "{\"nargout\": 1, \"rhs\": [10], \"outputFormat\": {\"mode\":\"small\"}}"
* Trying [::1]:9911...
* Connected to localhost (::1) port 9911
> POST /lib/mySqrt HTTP/1.1
> Host: localhost:9911
> User-Agent: curl/8.4.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 61
>
< HTTP/1.1 200 OK
< Content-Type: application/json
< Content-Length: 28
< Connection: Keep-Alive
<
{"lhs":[3.1622776601683795]}* Connection #0 to host localhost left intact
And the other thing I really wanted to understand is, why don't you guys release this library in opensource on github ... just to avoid things like this from happening, and encourage the open source community to maintain/enhance/provide bug fixes to this ... This is not a product, it's not really part of Matlab, it's just a plugin making the .NET to Matlab Server communication possible, nothing more - you don't have a license attached to it, and it is just s.NET code entirely disconnected from Matlab code base, so it would make sense to make it open source.
Maybe @Hitesh Kumar Dasika and @snikumbh - can you comment, I believe you are the author of the NuGet package.
Grazie mille!!!!
2 Kommentare
Nicole Bonfatti
am 12 Apr. 2024
Bearbeitet: Nicole Bonfatti
am 12 Apr. 2024
Thanks for the feedback about releasing source to the client libraries, its useful to know that people are interested in that!
As for your cast error, I believe you want to update the line where you create the client proxy as follows:
The code you posted is trying to create a proxy on a "MySqrt" object, but you defined the interface as a "MySqrtInterface" object.
Antworten (1)
Siraj
am 1 Aug. 2024
Hi!
I understand that you are encountering a "System.InvalidCastException" when using the MATLAB Production Server .NET Client. This error might be due to an unsupported MPS .NET client package with a specific version of the .NET Framework.
Firstly, you should check the compatibility of the .NET Framework you are using. MATLAB provides a function called "NET.isNETSupported" to check for the supported versions of Microsoft .NET. You can refer to the following link for more details on how to use this function.
If you find that your current .NET Framework version is not supported, you might need to switch to a compatible version.
If you need to change the .NET default environment on your Microsoft Windows platform, you can use the "dotnetenv" function. More information on how to use this function can be found in the following documentation. This might help in resolving any compatibility issues that are causing the casting error.
Additionally, it is important to be aware of any limitations to .NET support in MATLAB. You can check for these limitations at the following link:
As per my knowledge, the MPS .NET client package might not be supported with .NET Framework 4.0 but is supported with .NET Framework 4.5. Therefore, trying to use .NET Framework 4.5 could potentially resolve the issue you are facing.
Alternatively, if the issue persists, you can consider using the REST API provided by MATLAB Production Server. This approach can sometimes bypass the limitations encountered with the .NET client. You can refer to the following links for more details on using the REST API:
I hope this helps!
Thanks.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Call Web Services from MATLAB Using HTTP 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!