NuGet - mathworks.​prodserver​.dotnetcli​ent library

19 visualizaciones (últimos 30 días)
Andy
Andy el 3 de Abr. de 2024
Respondida: Siraj el 1 de Ag. de 2024
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:
MySqrtInterface me = client.CreateProxy<MySqrt>(new Uri(@"http://localhost:9911/lib"));
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 comentarios
Nicole Bonfatti
Nicole Bonfatti el 12 de Abr. de 2024
Editada: Nicole Bonfatti el 12 de Abr. de 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:
MySqrtInterface me = client.CreateProxy<MySqrtInterface>(new Uri(@"http://localhost:9911/lib"));
The code you posted is trying to create a proxy on a "MySqrt" object, but you defined the interface as a "MySqrtInterface" object.
Andy
Andy el 13 de Abr. de 2024
Editada: Andy el 14 de Abr. de 2024
It's not that sorry - the above is just a typo (tried multiple iterations), the above { Unable to cast object of type '...._+ } is persistent across many usecases. There's a Case/bug 6919906 open on this (can also see the nuget package was updated, maybe its fixed in latest). Workaround is using CreateComponentProxy. @Nicole Bonfatti, what would dramatically help, is to add .NET 4.0 support into this NuGet package, as there's still tons of stuff running on 4.0. Thx

Iniciar sesión para comentar.

Respuestas (1)

Siraj
Siraj el 1 de Ag. de 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.

Categorías

Más información sobre Call Web Services from MATLAB Using HTTP en Help Center y File Exchange.

Productos


Versión

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by