Assigning nullable types to an imported .NET class in Wonderware Application Server

StackOverflow https://stackoverflow.com/questions/19244007

  •  30-06-2022
  •  | 
  •  

Вопрос

I'm having a problem assigning values to a nullable type in the Wonderware ArchestrA IDE (2012 R2).

My imported .NET class looks like this:

    public class TestObject
    {
        public string Name { get; set; }

        public Nullable<int> MyNullableInt { get; set; }

        public int MyInt { get; set; }
    }

I then import this into the Galaxy using Import -> Script Function Library.

My ArchestrA script then consists of literally, just this:

dim NT as NullTest.TestObject;
NT = new NullTest.TestObject;
NT.MyNullableInt = 3;

The script validates, but but assigning to MyNullableInt causes a script error to be logged in the management console:

ProdCapability_001.GetMESWOData: {0896E675-F7D7-4F77-9FD2-20477058E072}: JIT Compiler encountered an internal limitation.

.NET 4.5 is installed on the server. Can imported .NET classes in Wonderware Application Server not use Nullable types? Or have I missed something?

Это было полезно?

Решение

Have discovered that generics are not supported, which explains the bizarre "Constructor overload not found" message. From the ArchestrA IDE Help:

Although QuickScript supports import libraries built with .NET CLR version 2.0.50727, it does not support any of the new language features introduced with .NET 2.0, such as generics.

So, looks like I need to create a class which supports the assignment of null for each .NET value type that I want to be able to assign null to, as opposed to using the Nullable class.

Другие советы

Wonderware has some missing functionality (nulls, generics, exception handling, using statements). However, if I recall correctly you can use DBNull in some cases (for example, if you want a blank cell in a table or if you're writing a null value to a database).

https://msdn.microsoft.com/en-us/library/system.dbnull.value%28v=vs.110%29.aspx

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top