You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
System.StackOverflowException when using DateTime in a struct with ReadStructAsync
I'm experiencing a System.StackOverflowException with HRESULT=0x800703E9 and the message "Exception_WasThrown" when trying to include a DateTime field in a structure in an S7.Net environment. This problem occurs because I am using structs to map directly to a database schema, allowing for direct CRUD operations upon successful mapping. The struct in question has 20 fields, some of which are date fields.
Here's the problematic field in the structure:
public System.DateTime ProductExpiryDate;
The application only functions correctly when all DateTime fields are removed from the structure. Does the ReadStructAsync method not support reading blocks of data that include Date, Time_And_Date, or LDT time types? There is no mention of this limitation in the documentation. Additionally, the documentation states that the "read struct" and "write struct" methods do not support strings, although using the S7String attribute allows strings to be read successfully, as shown below:
However, there are no attributes available for handling time types. Could someone clarify why this is the case and whether there is a workaround for including DateTime fields in data structures read by ReadStructAsync?
The library documentation does not mention limitations regarding DateTime data types, and while string types can be handled with the S7String attribute, there appears to be no equivalent for time types. I am aware of alternatives like ReadBytesAsync or ReadAsync, but using structs is preferable due to their direct mapping to the database schema.
The text was updated successfully, but these errors were encountered:
@keeleycenc please write the issue in English, so everyone can read it (w/o the use of translators of more or less good quality), and then it's way easier to be actionable on that issue.
Thanks!
keeleycenc
changed the title
为什么结构体包含DateTime字段,使用ReadStructAsync会出现无线递归导致的应用程序崩溃?
Why does including a DateTime field in a struct cause an application crash due to infinite recursion when using ReadStructAsync?
Apr 22, 2024
@gfoidl Thank you for your response and guidance! I have updated my question to English as requested and added some additional details to more accurately describe my problem and use case. Please take a look at the revised question, and I hope to receive further assistance or suggestions. Thank you again for your support and patience!
System.StackOverflowException when using DateTime in a struct with ReadStructAsync
I'm experiencing a System.StackOverflowException with HRESULT=0x800703E9 and the message "Exception_WasThrown" when trying to include a DateTime field in a structure in an S7.Net environment. This problem occurs because I am using structs to map directly to a database schema, allowing for direct CRUD operations upon successful mapping. The struct in question has 20 fields, some of which are date fields.
Here's the problematic field in the structure:
The application only functions correctly when all DateTime fields are removed from the structure. Does the ReadStructAsync method not support reading blocks of data that include Date, Time_And_Date, or LDT time types? There is no mention of this limitation in the documentation. Additionally, the documentation states that the "read struct" and "write struct" methods do not support strings, although using the S7String attribute allows strings to be read successfully, as shown below:
However, there are no attributes available for handling time types. Could someone clarify why this is the case and whether there is a workaround for including DateTime fields in data structures read by ReadStructAsync?
And here's how I'm calling ReadStructAsync:
The library documentation does not mention limitations regarding DateTime data types, and while string types can be handled with the S7String attribute, there appears to be no equivalent for time types. I am aware of alternatives like ReadBytesAsync or ReadAsync, but using structs is preferable due to their direct mapping to the database schema.
The text was updated successfully, but these errors were encountered: