带有新usercontrol的ResourceReferenceKeyNotFoundException

时间:2014-01-12 19:20:17

标签: c# wpf

我正在创建一个使用工具提示图标的小型C#应用程序。

但是,无论何时我创建一个新的usercontrol,我都会收到以下错误:

System.Windows.ResourceReferenceKeyNotFoundException
'tbNotifyIcon' resource not found.
at MS.Internal.Helper.FindResourceHelper.DoTryCatchWhen(Object arg)
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)

tbNotifyIcon是资源目录中的用户控件。代码工作正常,但是当我关闭用户控件时,设计器每次都会在此错误时崩溃。在新的用户控件中,未使用tbNotifyIcon,但我在设计器中收到错误。可能有什么不对?

1 个答案:

答案 0 :(得分:0)

我现在已经解决了这个问题,这与我想Caliburn执行一些我在构造函数中放置的代码有关。删除我的FindReference代码以从构造函数中找到UI元素后,这个问题就消失了。