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

Model compiler fails due to invalid DateTime format #156

Open
vepes opened this issue Jan 31, 2024 · 2 comments
Open

Model compiler fails due to invalid DateTime format #156

vepes opened this issue Jan 31, 2024 · 2 comments

Comments

@vepes
Copy link

vepes commented Jan 31, 2024

We are experiencing a problem with Model Compiler. When attempting to run Opc.Ua.ModelCompiler.exe compile or compile-nodesets command, the compiler stops and outputs an error: "[FormatException] String '' was not recognized as a valid DateTime."

The problem seems to happen in ValidateModel function in ModelDesignValidator.cs file. More accurately the line: DateTime? pd = (ns.PublicationDate != null) ? DateTime.Parse(ns.PublicationDate, null, DateTimeStyles.None) : null; fails to convert the DateTime.

When running in debugger, the ns.PublicationDate is shown in following format, which apparently is not valid UTC time format.

image

The problem is somehow related to executing environment, because on some of our laptops the Model Compiler is working fine.

@opcfoundation-org
Copy link
Contributor

https://en.wikipedia.org/wiki/ISO_8601 uses : not .
The time value IS invalid.
Not sure why it works sometimes.

@opcfoundation-org
Copy link
Contributor

Discovered that the function was localized when it should not be.
The date has . instead of :.

Fix will be added:

var dt = DateTime.Parse(ModelPublicationDate, CultureInfo.InvariantCulture, DateTimeStyles.None);

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