Xamlparser error after clickonce deployment. If the application crashes after installation

I created a WPF application with visual studio 2008 and created an installer for it. There is still nothing left. I realized that he lacked the automatic update function, and after several attempts at solving it, I decided to try deploying it. After successfully deploying to a network server, I noticed that the application crashes after installing the downloaded application. It complains about this:

Unable to create instance of "Login" defined in assembly "MyApplication, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null". The exception was caused by the purpose of the call. Error in the markup file "MyApplication; component / login.xaml" Line 1 Position 9.

here is stacktrace

in System.Windows.Markup.XamlParseException.ThrowException (String messages, Exception InnerException, Int32 LINENUMBER, Int32 linePosition Uri BaseUri, XamlObjectIds currentXamlObjectIds, XamlObjectIds contextXamlObjectIds, Type OBJECTTYPE)
in System.Windows.Markup.XamlParseException.ThrowException (ParserContext ParserContext, Int32, Int32 LINENUMBER linePosition, message string, Exception InnerException) in System.Windows.Markup.BamlRecordReader.ThrowExceptionWithLine (message String, innerException exception)
in System.Windows.Markup.BamlRecordReader.CreateInstanceFromType (Type Type, Int16 typeId, Boolean throwOnFail)
on System.Windows.Markup.BamlRecordReader.GetElementAndFlags (BamlElementStartRecord bamlElementStartRecord, Object & element, ReaderFlags & flags, Type & delayCreatedType, Int16 & delayCreatedTypeId)
in System.Windows.Markup.BamlRecordReader.BaseReadElementStartRecord (BamlElementStartRecord bamlElementRecord)
in System.Windows.Markup.BamlRecordReader.ReadElementStartRecord (BamlElementStartRecord bamlElementRecord)
in System.Windows.Markup.BamlRecordReader.ReadRecord (BamlRecord bamlRecord)
in System.Windows.Markup.BamlRecordReader.Read (Boolean singleRecord)
in System.Windows.Markup.TreeBuilderBamlTranslator.ParseFragment ()
in System.Windows.Markup.TreeBuilder.Parse ()
in System.Windows.Markup.XamlReader.LoadBaml (stream stream, ParserContextContext parser, parent object, closeStream boolean method)
in System.Windows.Application.LoadBamlStreamWithSyncInfo (stream stream, ParserContext pc)
in System.Windows.Application.LoadComponent (Uri resourceLocator, Boolean bSkipJournaledProperties)
in System.Windows.Application.DoStartup ()
in System.Windows.Application. <.ctor> b__0 (object not used)
in System.Windows.Threading.ExceptionWrapper.InternalRealCall (delegate callback, object args, boolean isSingleParameter)
in System.Windows.Threading.ExceptionWrapper.TryCatchWhen (object source, delegate callback, args objects, boolean isSingleParameter, delegate catchHandler)
in System.Windows.Threading.Dispatcher.WrappedInvoke (delegate callback, args, boolean isSingleParameter, delegate catchHandler)
in System.Windows.Threading.DispatcherOperation.InvokeImpl ()
in System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext (object state)
in System.Threading.ExecutionContext.runTryCode (Object userData)
in System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup (TryCode code, CleanupCode return code, userData object)
in System.Threading.ExecutionContext.RunInternal (ExecutionContextual executionContext, ContextCallback callback, Object state)
in System.Threading.ExecutionContext.Run (ExecutionContextual executionContext, ContextCallback callback, Object state)
in System.Windows.Threading.DispatcherOperation.Invoke ()
in System.Windows.Threading.Dispatcher.ProcessQueue ()
on System.Windows.Threading.Dispatcher.WndProcHook (IntPtr HWND, Int32 MSG, IntPtr, IntPtr wParam, LPARAM, Boolean & pumped)
on MS.Win32.HwndWrapper.WndProc (IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean & processed)
in MS.Win32.HwndSubclass.DispatcherCallbackOperation (Object o)
in System.Windows.Threading.ExceptionWrapper.InternalRealCall (delegate callback, object args, boolean isSingleParameter)
in System.Windows.Threading.ExceptionWrapper.TryCatchWhen (object source, delegate callback, args objects, boolean isSingleParameter, delegate catchHandler)
in System.Windows.Threading.Dispatcher.WrappedInvoke (delegate callback, args, boolean isSingleParameter, delegate catchHandler)
in System.Windows.Threading.Dispatcher.InvokeImpl (DispatcherPriority priority, TimeSpan timeout, delegation method, object arguments, boolean isSingleParameter)
in System.Windows.Threading.Dispatcher.Invoke (DispatcherPriority priority, Delegate method, arg object)
on MS.Win32.HwndSubclass.SubclassWndProc (IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage (MSG & msg)
in System.Windows.Threading.Dispatcher.PushFrameImpl (DispatcherFrame)
in System.Windows.Threading.Dispatcher.PushFrame (DispatcherFrame)
in System.Windows.Threading.Dispatcher.Run ()
in System.Windows.Application.RunDispatcher (Object ignore)
in System.Windows.Application.RunInternal (window window)
in System.Windows.Application.Run (window window)
in System.Windows.Application.Run ()
on myApplication.App.Main ()

here is just the area from which the debugger points to

<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"> 

But the installer version, as in msi from the installation project, works fine. So I don’t see where the error comes from, because I have a design. Question 1 : Does anyone have a similar problem or is this a known problem?
Question 2 . If this is a known issue, then what are the alternatives. I can refuse clickonce, but then my auto-update function will be lost (since there is not one that is not ovekill or seriously outdated that I can find right now).
Thanks for reading this and for pointing me in the right direction.

+4
source share
1 answer

If you go to the ClickOnce cache and find the executable file for your application and double-click on it, it still does not work? If so, then this is not a ClickOnce problem in itself. Perhaps you are missing any assembly in your deployment that is required. Or you are doing something that ClickOnce does not allow, for example, accessing a folder that requires administrative privileges.

You can also try to run it from the \ bin \ release folder after the build is complete, but this will not tell you if you have an assembly on your computer that you are using that is not being deployed.

ClickOnce Cache for Windows 7 (and Vista) is here:
C: \ Users \ username \ AppData \ Local \ Apps \ 2.0 \ obfuscatedfolder \ obfuscatedfolder

From there, for the application of winning forms, he creates two folders: one of them is xxxx ... exe_etc and one of them is called xxxx ... tion_etc ... The one that starts with xxxx_tion (where xxxx = the first four characters of your assembly name) is the one from which the application is running. I'm not sure the folder names are the same for the WPF application, but hopefully they are not too different. The executable file will be located in only one folder. (And yes, you think it will be in the xxxx ... exe_etc folder, but it is not.)

EDIT - ADDED INFORMATION

As for the missing images: are they included in the project as files? If so, make sure that the assembly action is "content" and the "copy to output directory" property is set to "always copy." Otherwise, they will not be included in the deployment.

There is the same problem for the database. It should be included in the project, and the properties should be set accordingly (set "copy ..." to "copy if newer"). Alternatively, open the Application Files dialog box and see if it is marked as Enable (data). If so, then it is deployed to the data directory. If you post it this way when you publish the new version, it will copy the data forward to the new folders. You can find it programmatically using the ApplicationDeployment.DataDirectory property.

I generally do not recommend trusting your ClickOnce data. If you put something as data and mark the date / time on your local version, ClickOnce will deploy the new version and put the old version in a subfolder with the name. \ Pre. This is dangerous for me, because you can accidentally change the data. SQLCE changes the date / time stamp if you simply open the database to look at the table structures. Therefore, I move the data and process the update of the database itself. If you want more information about this, check out your blog post to keep your data safe from ClickOnce updates .

0
source

Source: https://habr.com/ru/post/1311202/


All Articles