0

My application works fine in debug and release modes when I launch it from Visual Studio, but it throws an exception (which I get from Event Viewer) and this is the stack trace

Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Windows.Markup.XamlParseException
Stack:
   at System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri)
   at System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader, Boolean, System.Object, System.Xaml.Permissions.XamlAccessLevel, System.Uri)
   at System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream, System.Windows.Markup.ParserContext, System.Object, Boolean)
   at System.Windows.Application.LoadBamlStreamWithSyncInfo(System.IO.Stream, System.Windows.Markup.ParserContext)
   at System.Windows.Application.LoadComponent(System.Uri, Boolean)
   at System.Windows.Application.DoStartup()
   at System.Windows.Application.<_ctor>b__0(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
   at System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)
   at System.Windows.Application.RunDispatcher(System.Object)
   at System.Windows.Application.RunInternal(System.Windows.Window)
   at System.Windows.Application.Run(System.Windows.Window)
   at CKeeper.App.Main()

None of these methods looks familiar to me. How can I find the source looking this stack trace?

This is the using section,

using CKeeper.Controllers;
using CKeeper.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml;
ozgur
  • 2,549
  • 4
  • 25
  • 40
  • 1
    Why don't you use debug mode then? – wingerse Oct 08 '15 at 20:38
  • Queue log4net, elmah, etc. discussion. – Brad Christie Oct 08 '15 at 20:38
  • sounds like a `Reference / DLL` Issue you need to make sure that your dlls are set to CopyToLocal = true when deploying can you display or show us what the `using section in the header looks like` – MethodMan Oct 08 '15 at 20:39
  • Note that this kind of Exception/Stacktrace is common if an exception is thrown in the constructor of a UserControl/Window. You need better application logging so you can see the inner exception which has the details of what actually went wrong. – Mike Zboray Oct 08 '15 at 20:44
  • @MethodMan I added using section, if I understood you correctly. Idk if you are talking about this one. – ozgur Oct 08 '15 at 20:44
  • yes.. now in the project you need to make sure that those references are also in the `references` node in your project also make sure the properties for all of them have the `CopyToLocal` property set to `=true` what version of .net framework is the project set to use also 4.0, 4.5, etc...? – MethodMan Oct 08 '15 at 20:45
  • @mikez How can I log this error when I don't have any clue about where it is. In debug mode it works perfectly? – ozgur Oct 08 '15 at 20:46
  • 1
    You don't need to know the cause in order to log it. You hook into the mechanisms described [here](http://stackoverflow.com/q/1472498/517852). – Mike Zboray Oct 08 '15 at 20:48
  • you can add some poor mans logging to a file or you can create a method everywhere in your code Passing the Method name to log to an event log.. this can be tracked very easily if the program is small or it will take some effort on your part to add additional lines of code to your methods or something like this `System.Diagnostics.Trace.WriteLine("YourMethodName")` – MethodMan Oct 08 '15 at 20:49
  • @mikez Very helpful suggestion. I actually did not know that. thank you – ozgur Oct 08 '15 at 20:52
  • build in debug mode. then attach to the process on the server. – tdbeckett Oct 08 '15 at 21:11
  • The stacktrace is in reverse order so the exception is at the first line of the exception (not the last). I appears the error is occurring when you are loading an xaml. It appear to be a file that gets loaded. Make sure the path of the xaml exists. – jdweng Oct 08 '15 at 21:45

0 Answers0