【发布时间】:2010-05-28 11:17:08
【问题描述】:
我已经用 Visual Studio 2008 构建了一个 WPF 应用程序并为其创建了一个安装程序。到目前为止工作正常。我意识到它缺少自动更新功能,在尝试了几种解决方案后,我决定尝试 clickonce 部署.在网络服务器上成功部署后,我注意到应用程序在安装下载的应用程序后崩溃。它抱怨这个:
无法创建在程序集“MyApplication,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null”中定义的“Login”实例。调用的目标已引发异常。标记文件“MyApplication;component/login.xaml”第 1 行位置 9 中的错误。
这里是堆栈跟踪
在 System.Windows.Markup.XamlParseException.ThrowException(字符串消息,异常 innerException,Int32 lineNumber,Int32 linePosition,Uri baseUri,XamlObjectIds currentXamlObjectIds,XamlObjectIds contextXamlObjectIds,类型 objectType)
在 System.Windows.Markup.XamlParseException.ThrowException(ParserContext parserContext,Int32 lineNumber,Int32 linePosition,字符串消息,异常 innerException) 在 System.Windows.Markup.BamlRecordReader.ThrowExceptionWithLine(字符串消息,异常 innerException)
在 System.Windows.Markup.BamlRecordReader.CreateInstanceFromType(类型类型,Int16 typeId,布尔 throwOnFail)
在 System.Windows.Markup.BamlRecordReader.GetElementAndFlags(BamlElementStartRecord bamlElementStartRecord,Object& 元素,ReaderFlags& 标志,Type& delayCreatedType,Int16& delayCreatedTypeId)
在 System.Windows.Markup.BamlRecordReader.BaseReadElementStartRecord(BamlElementStartRecord bamlElementRecord)
在 System.Windows.Markup.BamlRecordReader.ReadElementStartRecord(BamlElementStartRecord bamlElementRecord)
在 System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord bamlRecord)
在 System.Windows.Markup.BamlRecordReader.Read(Boolean singleRecord)
在 System.Windows.Markup.TreeBuilderBamlTranslator.ParseFragment()
在 System.Windows.Markup.TreeBuilder.Parse()
在 System.Windows.Markup.XamlReader.LoadBaml(流流,ParserContext parserContext,对象父级,布尔 closeStream)
在 System.Windows.Application.LoadBamlStreamWithSyncInfo(流流,ParserContext pc)
在 System.Windows.Application.LoadComponent(Uri 资源定位器,布尔 bSkipJournaledProperties)
在 System.Windows.Application.DoStartup()
在 System.Windows.Application.<.ctor>b__0(未使用的对象)
在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(委托回调,对象参数,布尔 isSingleParameter)
在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(对象源,委托回调,对象 args,布尔 isSingleParameter,委托 catchHandler)
在 System.Windows.Threading.Dispatcher.WrappedInvoke(委托回调,对象参数,布尔 isSingleParameter,委托 catchHandler)
在 System.Windows.Threading.DispatcherOperation.InvokeImpl()
在 System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(对象状态)
在 System.Threading.ExecutionContext.runTryCode(Object userData)
在 System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode 代码,CleanupCode backoutCode,对象 userData)
在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback 回调, 对象状态)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback 回调, 对象状态)
在 System.Windows.Threading.DispatcherOperation.Invoke()
在 System.Windows.Threading.Dispatcher.ProcessQueue()
在 System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd,Int32 msg,IntPtr wParam,IntPtr lParam,布尔值&处理)
在 MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& 处理)
在 MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(委托回调,对象参数,布尔 isSingleParameter)
在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(对象源,委托回调,对象 args,布尔 isSingleParameter,委托 catchHandler)
在 System.Windows.Threading.Dispatcher.WrappedInvoke(委托回调,对象参数,布尔 isSingleParameter,委托 catchHandler)
在 System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority 优先级,TimeSpan 超时,委托方法,对象参数,布尔 isSingleParameter)
在 System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority 优先级,委托方法,对象 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 框架)
在 System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame 框架)
在 System.Windows.Threading.Dispatcher.Run()
在 System.Windows.Application.RunDispatcher(对象忽略)
在 System.Windows.Application.RunInternal(窗口窗口)
在 System.Windows.Application.Run(窗口窗口)
在 System.Windows.Application.Run()
在 myApplication.App.Main()
这里只是调试器指向的区域
<Window x:Class="MyApplication.Login"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:src="clr-namespace:MyApplication"
xmlns:UI="clr-namespace:UI;assembly=UI"
Title="My Application" Height="400" Width="550" ResizeMode="NoResize" WindowStyle="ThreeDBorderWindow" WindowStartupLocation="CenterScreen" Name="Logine" Loaded="Logine_Loaded" Closed="Logine_Closed" Icon="orLogo.ico">
但是安装项目中的 msi 中的安装程序版本工作正常。所以我看不到错误来自哪里,因为我可以看到设计视图。
问题 1:有没有人有类似的问题,还是已知问题?
问题 2:如果这是已知问题,那么有什么替代方法。我可能会放弃 clickonce,但我的自动更新功能将迷路了(因为我现在可以找到没有过时或严重过时的东西)。
感谢您阅读本文并为我指明正确的方向。
【问题讨论】:
-
XamlParseExceptions 通常是由窗口构造函数期间发生的另一个异常引起的。您可以访问异常的 InnerException 属性吗?如果可以,它包含什么?
-
ok
JustABIll抱歉我迟到的反馈。实际上你是对的。这是ctor中的null pointer exception。这就是我在innerException 中的全部内容。现在这让我很烦恼查看 clickonce 的安装位置。根据RobinDotNet的帖子,我可能对 XP 有一个想法:C:\Documents and Settings\Owner\Local Settings\Application Data\assembly\dl3\GMR0THT4.V0C\1TGK7XE3.C5Z那里一团糟。大量的文件夹。事实上,可能导致问题的一件事是图像 src和 sqlite db。我看不到 images 文件夹,也看不到 sqlite db.how?
标签: wpf deployment clickonce xamlparseexception