Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom struct throwing NotSupportedException on getting JsonEncodingId #185

Open
OlivierVerhaegen opened this issue Aug 5, 2024 · 10 comments

Comments

@OlivierVerhaegen
Copy link

OlivierVerhaegen commented Aug 5, 2024

Hi All,

I noticed that the JsonEncodingId currently throws an NotSupportedException although the class implements IJsonEncodeable. The class was generated from a custom struct in the NodeSet2.xml model.
This happens when running Server.Factory.AddEncodeableTypes(...).

Can someone explain why this is implemented this way and why custom structs are not supported for JSON encoding?

image

image

Thanks already for the information.

@opcfoundation-org
Copy link
Contributor

If the JsonEncodingIds are not defined in the NodeSet then it can't be implemented.
The JsonEncodingIds are optional in 1.05.03 and removed from 1.05.4.
The DataTypeId is used instead.

@OlivierVerhaegen
Copy link
Author

Hi thank you for the quick response!

I'm currently using Model version 1.4.10 so that would explain why no JsonEncodingIds are available?
How should I implement this, just by updating to 1.05.4?

@opcfoundation-org
Copy link
Contributor

You not get an exception in AddEncodeableTypes since there is a try catch block to suppress this error.

Can you explain exactly where the exception is coming from?

@OlivierVerhaegen
Copy link
Author

I cannot see the insides of AddEncodeableTypes but I only get the exception when running in debug mode.

@opcfoundation-org
Copy link
Contributor

Code is here: https://github.com/OPCFoundation/UA-.NETStandard/blob/master/Stack/Opc.Ua.Core/Types/Encoders/EncodeableFactory.cs

Do you have some setting enabled to stop on exception? This can cause the debugger to halt even if an exception is handled.

@OlivierVerhaegen
Copy link
Author

This seems that the exception is categorized as "User-Unhandled".
When I disable the breakpoint optionf for these kind of exceptions the code runs but weirdly I don't get the error logs defined in the code you mentioned above.
I only get these logs:
image

@opcfoundation-org
Copy link
Contributor

opcua.dll means you are using someone else's code base. where did you get the dll from?

@OlivierVerhaegen
Copy link
Author

I'm just compiling my own project using .NET core on Linux and removed a part of the project name, hence why you only see opcua.dll in the name

@opcfoundation-org
Copy link
Contributor

You should not get an error. AddEncodeableTypes suppresses the NotImplementedException and continues.

@OlivierVerhaegen
Copy link
Author

Yeah I know I've read the code (not only master but also specific to the version I'm using).
I'm using the following nuget package: <PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Server" Version="1.5.374.78" />

.Net Core version 8.0.303 on Ubuntu 20.04.3 LTS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants