SecurityException未处理与IPropertyNotify相关

时间:2013-03-06 19:57:38

标签: c# wpf data-binding jint

我遇到了IPropertyNotify的问题。我有一个在我的WPF项目中引用的.dll中定义和创建的对象(DataPoint)。我正在尝试在WPF表单上设置与DataPoint.Value和TextBox的绑定。但是,当我在DataPoint中调用PropertyNotify时,我得到一个SecurityException是未处理的错误,并且绝对没有调试信息,因为“没有为任何调用堆栈帧加载符号。源代码无法显示。”此外,它告诉我,我需要完全信任才能正常运行,尽管这完全在一台没有网络的台式机上运行。

System.Security.SecurityException was unhandled
  HResult=-2146233078
  Message=Request failed.
  Source=mscorlib
  StackTrace:
       at System.RuntimeMethodHandle.PerformSecurityCheck(Object obj, RuntimeMethodHandleInternal method, RuntimeType parent, UInt32 invocationFlags)
       at System.RuntimeMethodHandle.PerformSecurityCheck(Object obj, IRuntimeMethodInfo method, RuntimeType parent, UInt32 invocationFlags)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
       at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
       at MS.Internal.Data.PropertyPathWorker.GetValue(Object item, Int32 level)
       at MS.Internal.Data.PropertyPathWorker.RawValue(Int32 k)
       at MS.Internal.Data.PropertyPathWorker.RawValue()
       at MS.Internal.Data.ClrBindingWorker.RawValue()
       at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
       at System.Windows.Data.BindingExpression.ScheduleTransfer(Boolean isASubPropertyChange)
       at MS.Internal.Data.ClrBindingWorker.NewValueAvailable(Boolean dependencySourcesChanged, Boolean initialValue, Boolean isASubPropertyChange)
       at MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)
       at MS.Internal.Data.ClrBindingWorker.ScheduleTransferOperation(Object arg)
       at MS.Internal.Data.DataBindOperation.Invoke()
       at MS.Internal.Data.DataBindEngine.ProcessCrossThreadRequests()
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.DispatcherOperation.InvokeImpl()
       at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Windows.Threading.DispatcherOperation.Invoke()
       at System.Windows.Threading.Dispatcher.ProcessQueue()
       at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.Run()
       at System.Windows.Application.RunDispatcher(Object ignore)
       at System.Windows.Application.RunInternal(Window window)
       at System.Windows.Application.Run(Window window)
       at System.Windows.Application.Run()
       at EmulationGUIRewriteTest.App.Main()
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

是我能够摆脱异常的。我已经尝试过调用ProperyChanged方法调用,但这似乎根本没有改进它,我甚至尝试了一个全新的解决方案,排除了我可能偶然发生的任何安全性变化。

所有关于此的研究都让我涉及网络服务器或类似的东西,所以我完全难过。

绑定代码如下所示:

TextBox c = new TextBox();
c.Text = data.Value.ToString();

Binding b = new Binding();
b.Path = new PropertyPath("Value");
b.Mode = BindingMode.TwoWay;
b.Source = data;
b.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;

c.SetBinding(TextBox.TextProperty, b);

PropertyChanged方法如下所示:

void OnPropertyChanged(string name)
{
    if (PropertyChanged != null)
    {
        PropertyChanged.Invoke(this, new PropertyChangedEventArgs(name));
        Console.WriteLine("TESTTESTTEST");
    }
}

我在安全异常之前的输出上看到Console.WriteLine()

0 个答案:

没有答案