john.hui
03-10-2007, 09:00 AM
Hi Spring Team,
I am trying to invoke a property within SpEL but I have met with some difficulties. I have tried to simplify everything to isolate the crux of the matter.
I have the following class:
Public Class Test
Public Shared ReadOnly Property TestProperty(ByVal str As String) As String
Get
Return "Success"
End Get
End Property
End Class
I want to invoke the TestProperty property within an SpEL.
So I execute the following line of code:
obj = Spring.Expressions.ExpressionEvaluator.GetValue(No thing, "Test.TestProperty('hello')")
I get an ArgumentException exception with the message:
"Method with a specified number and types of arguments does not exist."
So I tried again with the following line of code:
obj = Spring.Expressions.ExpressionEvaluator.GetValue(No thing, "Test.TestProperty['hello']")
I get an InvalidProgramException exception with the message:
"Common Language Runtime detected an invalid program."
Source: "Spring.DynamicReflection"
StackTrace: " at Spring.DynamicReflection.Property_TestProperty_29a 3cb00b4f74c8abc00045102c29fa7.GetValue(Object target)
at Spring.Util.DynamicReflection.SafeProperty.GetValu e(Object target)
at Spring.Expressions.PropertyOrFieldNode.PropertyVal ueAccessor.Get(Object context)
at Spring.Expressions.PropertyOrFieldNode.GetProperty OrFieldValue(Object context)
at Spring.Expressions.PropertyOrFieldNode.Get(Object context, IDictionary variables)
at Spring.Expressions.BaseNode.GetValue(Object context, IDictionary variables)
at Spring.Expressions.Expression.Get(Object context, IDictionary variables)
at Spring.Expressions.BaseNode.GetValue(Object context, IDictionary variables)
at Spring.Expressions.ExpressionEvaluator.GetValue(Ob ject root, String expression)
at Main.Main.Main() in E:\PAC\20070306 with BuyerGroupsFactoryMgr\Main\Main.vb:line 103
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context( Object state)
at System.Threading.ExecutionContext.Run(ExecutionCon text executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()"
I need some help here to understand what is happenning. This is the first time I have seen a "Common Language Runtime detected an invalid program." exception message.
Thanks in advance.
John Hui
I am trying to invoke a property within SpEL but I have met with some difficulties. I have tried to simplify everything to isolate the crux of the matter.
I have the following class:
Public Class Test
Public Shared ReadOnly Property TestProperty(ByVal str As String) As String
Get
Return "Success"
End Get
End Property
End Class
I want to invoke the TestProperty property within an SpEL.
So I execute the following line of code:
obj = Spring.Expressions.ExpressionEvaluator.GetValue(No thing, "Test.TestProperty('hello')")
I get an ArgumentException exception with the message:
"Method with a specified number and types of arguments does not exist."
So I tried again with the following line of code:
obj = Spring.Expressions.ExpressionEvaluator.GetValue(No thing, "Test.TestProperty['hello']")
I get an InvalidProgramException exception with the message:
"Common Language Runtime detected an invalid program."
Source: "Spring.DynamicReflection"
StackTrace: " at Spring.DynamicReflection.Property_TestProperty_29a 3cb00b4f74c8abc00045102c29fa7.GetValue(Object target)
at Spring.Util.DynamicReflection.SafeProperty.GetValu e(Object target)
at Spring.Expressions.PropertyOrFieldNode.PropertyVal ueAccessor.Get(Object context)
at Spring.Expressions.PropertyOrFieldNode.GetProperty OrFieldValue(Object context)
at Spring.Expressions.PropertyOrFieldNode.Get(Object context, IDictionary variables)
at Spring.Expressions.BaseNode.GetValue(Object context, IDictionary variables)
at Spring.Expressions.Expression.Get(Object context, IDictionary variables)
at Spring.Expressions.BaseNode.GetValue(Object context, IDictionary variables)
at Spring.Expressions.ExpressionEvaluator.GetValue(Ob ject root, String expression)
at Main.Main.Main() in E:\PAC\20070306 with BuyerGroupsFactoryMgr\Main\Main.vb:line 103
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context( Object state)
at System.Threading.ExecutionContext.Run(ExecutionCon text executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()"
I need some help here to understand what is happenning. This is the first time I have seen a "Common Language Runtime detected an invalid program." exception message.
Thanks in advance.
John Hui