WPF编程之找不到资源“window1.xaml”之谜

来源:互联网 发布:唯唯诺诺的性格知乎 编辑:程序博客网 时间:2024/06/05 03:51

当你运行程序时提示:

找不到资源“window1.xaml”。

System.IO.IOException was unhandled
  Message="找不到资源“window1.xaml”。"
  Source="PresentationFramework"
  StackTrace:
       在 MS.Internal.AppModel.ResourcePart.GetStreamCore(FileMode mode, FileAccess access)
       在 System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess access)
       在 System.IO.Packaging.PackWebResponse.CachedResponse.GetResponseStream()
       在 System.IO.Packaging.PackWebResponse.GetResponseStream()
       在 System.IO.Packaging.PackWebResponse.get_ContentType()
       在 MS.Internal.WpfWebRequestHelper.GetContentType(WebResponse response)
       在 MS.Internal.WpfWebRequestHelper.CreateRequestAndGetResponseStream(Uri uri, ContentType& contentType)
       在 System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
       在 SDKSample.Window1.InitializeComponent()
       在 SDKSample.Window1..ctor()
       在 SDKSample.app.AppStartingUp(Object sender, StartupEventArgs e)
       在 System.Windows.Application.OnStartup(StartupEventArgs e)
       在 System.Windows.Application.<.ctor>b__0(Object unused)
       在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
       在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       在 System.Windows.Threading.DispatcherOperation.InvokeImpl()
       在 System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
       在 System.Threading.ExecutionContext.runTryCode(Object userData)
       在 System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       在 System.Windows.Threading.DispatcherOperation.Invoke()
       在 System.Windows.Threading.Dispatcher.ProcessQueue()
       在 System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       在 MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       在 MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
       在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       在 System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
       在 System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
       在 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       在 MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       在 System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       在 System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       在 System.Windows.Threading.Dispatcher.Run()
       在 System.Windows.Application.RunInternal(Window window)
       在 System.Windows.Application.Run(Window window)
       在 System.Windows.Application.Run()
       在 SDKSample.app.Main()
       在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       在 System.Threading.ThreadHelper.ThreadStart()
  InnerException:


这个问题可以说是有点牛
为什么呢?
她在以前winform出现过,就是没有设定解决方案或是项目启动(窗体)
这个设定在VS中为解决方案或是项目属性中设置
但是你会问 我新建一个WpfApplication 时候 那里设定为空啊(Not Set)
呵呵 这个就不要问我 了,找不到资源“window1.xaml”解决方法就是设定解决方案启动为window1.xaml(启动窗体)
有时候VS很霸道,他就不给你设定window1.xaml为启动窗体,就是下拉列表就没有window1.xaml
怎么办?
直接用记事本打开项目文件比如Visual C# Project file
那个是个XML格式文件(不要问我什么是XML)
修改
  <StartupObject>Window1.xaml</StartupObject>
如果还是不行就新建一个工程,导入文件........

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 千牛上怎么改淘宝密码忘记了怎么办 公司收了代理商押金到期不退怎么办 淘宝显示签收但是我没收到货怎么办 淘宝东西没收到显示签收了怎么办 开拼多多店铺的密码忘了怎么办 拼多多密码跟店铺名忘了怎么办 闲鱼上卖出的宝贝被调包了怎么办 上传身份证照片说格式错误该怎么办 我给厂里打的款不给发货怎么办 净值接近不定期份额折算阀值怎么办 有锁电信4g掉了怎么办 在电脑中找不到想作废的发票怎么办 科目三补考费发票丢了怎么办 母婴店飞鹤奶粉突然厂家撤货怎么办 澳门买的保健品感觉是假的怎么办 淘宝买东西提交需求时卡死了怎么办 天猫精灵显示为离线状态怎么办 退货多被淘宝店铺拉入黑名单怎么办 天猫订单3天不发货怎么办 新开的厨卫店越来越没生意怎么办 淘宝积分不够领不到购物津贴怎么办 穿越火线精英集结号积分不足怎么办 天猫购物津贴领多了怎么办 车贷逾期车被开走还不清全款怎么办 孩子特别懒不爱动又胖怎么办 微信的聊天记录被限制了怎么办 门面租金交了一年对方不租了怎么办 离职后社保怎么办 无忧保专业可靠 淘宝店铺被投诉到监管局怎么办 淘宝买家每天都来店铺骚扰怎么办 电脑安装软件时解压出现问题怎么办 公婆不尊重你的父母做媳妇的怎么办 手机扣扣接收不上文件怎么办 买了商铺付了首付商铺倒闭了怎么办 宝宝刚满月不喜欢在床上睡怎么办 别人给我打了收货款不发货怎么办 业务员私收货款公司不发货怎么办 付款后商家没发货也不退钱怎么办 苹果7P修过主板耗电严重怎么办 oppo手机进水了开不了机怎么办 手机弯了变形但不影响使用怎么办