Sep 29, 2012 at 9:23 AM
Edited Sep 29, 2012 at 9:25 AM
I have a strange problem with using stuff from the .NET library within an event handler. I might just be doing it all wrong, but here's an example of what I'm trying to do:
var wnd = new System.Windows.Window();
wnd.Title = "Example dialog";
var btn = new System.Windows.Controls.Button();
btn.Content = "Test";
wnd.Content = btn;
If I run the example without the MessageBox inside the event, or if I use it outside the event, it works just fine. I got the "Use of CLR is not allowed" error, so I searched and found this
thread. I tried downloading the latest Jint from the source code repository, but unfortunately that gave me a lot more trouble, where
I couldn't even instantiate a new string (var s = new System.String()) or any other CLR object for that matter.
I then tried to see what had changed in relation to the "CLR not allowed" problem and changed a line in ExecutionVisitor.cs in the version 0.9.2 that I was using. It now gives
me the following error instead:
"Exception of type 'Jint.Native.JsException' was thrown."
Value: Function expected.
This is still related to the code in the event. Am I doing something completely wrong here? Hope you can help :)