我已经用 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,Type objectType)
在 System.Windows.Markup.XamlParseException.ThrowException(ParserContext parserContext,Int32 lineNumber, Int32 linePosition, String message, Exception innerException) at System.Windows.Markup.BamlRecordReader.ThrowExceptionWithLine(String message, Exception innerException)
at System.Windows.Markup.BamlRecordReader.CreateInstanceFromType(Type type, Int16 typeId, Boolean throwOnFail)
在 System.Windows.Markup.BamlRecordReader.GetElementAndFlags(BamlElementStartRecord bamlElementStartRecord, Object& element, ReaderFlags& flags, 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 resourceLocator, Boolean bSkipJournaledProperties)
at System.Windows.Application.DoStartup()
at System.Windows.Application.<.ctor>b__0(Object used)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(对象源,委托回调,对象参数,布尔 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)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at 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, Boolean& 处理)
在 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(委托回调, System.Windows.Threading.ExceptionWrapper.TryCatchWhen 处的对象 args,布尔 isSingleParameter)
(对象源,委托回调,对象 args,布尔 isSingleParameter,委托 catchHandler)
在 System.Windows.Threading.Dispatcher.WrappedInvoke(委托回调,对象参数,布尔 isSingleParameter,委托 catchHandler)
在 System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority 优先级,TimeSpan 超时,委托方法,对象参数,布尔 isSingleParameter)
在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(Object ignore)
在 System.Windows.Application.RunInternal(Window window)
在 System.Windows.Application.Run(Window window)
在 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:如果这是一个已知问题,那么还有什么可供选择的。我可能会放弃点击,但我的自动更新功能将丢失(因为没有我现在可以找到的不是过时或严重过时的) .
感谢您阅读本文并为我指明正确的方向。