PDA

View Full Version : Basic Expression question


javajunky
03-01-2007, 12:29 PM
Hi, I'm trying to do something with Expressions, and I'm not sure if it should work or not! I was hoping to evaluate the result of several static method calls and populate a property with the result thereof: My definition is as follows:


<object type="Index.aspx">
<property name="Test" expression="System.Environment.SpecialFolder.LocalApplicationD ata.ToString()"/>
</object>


But this fails horribly with the exception:

[NullValueInNestedPathException: Cannot initialize property or field node because its context is null.]


Is this the expected behaviour? Or have I just missed something simple [hopefully :)]

incidentally, if I replace the expression attribute's value with a string literal of the form 'foo'. Then the value of the property is correctly set to this value.

Thanks :)

Aleks Seovic
03-01-2007, 07:36 PM
The problem here is that you are using fully-qualified type name.

You have two options:

1. Register type alias for the System.Environment class and change expression to use this alias.

2. Encluse fully-qualified type name into T(): T(System.Environment).SpecialFolder...

Other than that, you should be able to do what you are trying...

- Aleks