Closed gfs closed 5 years ago
Hey @gfs,
None of the classes in this library is serializable. Therefore this is expected. A lot of properties might throw NotSupportedException
or InvalidOperationException
.
Also, there is a 1-1 relationship for IRule
classes and the underlying COM objects (in fact every property value requested from the COM object and then translated when used in realtime) and even if you serialize them it is not possible to deserialize that exact instance. I can make it more serialize friendly but the extent of these facts won't allow for full compatibility.
I suggest you use another class to hold the information you need and then try to serialize that one. For deserialization, the best way is to go through all rules and find the one most similar to the information you already saved or serialize and hope that nobody modified it in the meanwhile.
For your specific problem with the SingleIP
class, however, since it is a child of the System.Net.IPAddress
class you might be interested in the following SO question:
https://stackoverflow.com/questions/18668617/json-net-error-getting-value-from-scopeid-on-system-net-ipaddress
Thanks for the response! Makes sense to me.
It is caused by an underlying failure of the
IAddress []
to properly serialize.Here's a minimum viable demo of the broken behavior:
Which results in:
You don't need to serialize the whole Rule for this behavior. I isolated each field to determine it was the addresses. For example, this also will not work:
JsonConvert.SerializeObject(rule.LocalAddresses)