title: System.AggregateException was unhandled. Message=One or more errors occurred. InnerException: System.Windows.Markup.XamlParseException
body: <p>Presently, I am attempting to create a Windows Service application.  When I setup the service to debug as indicated in this article, it works fine:</p>
  
  <p><a href="http://www.codeproject.com/Articles/10153/Debugging-Windows-Services-under-Visual-Studio-NET" rel="nofollow">http://www.codeproject.com/Articles/10153/Debugging-Windows-Services-under-Visual-Studio-NET</a></p>
  
  <p>Then, if I attempt to setup the windows service in this way:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using ServiceProcess.Helpers;
  using System.ServiceProcess;
  using System.Text;
  using System.IO;
  
  namespace MyNamespace
  {
      static class Program
      {
          private static readonly List&lt;ServiceBase&gt; _servicesToRun =
              new List&lt;ServiceBase&gt;();
  
          /// &lt;summary&gt;
          /// The main entry point for the application.
          /// &lt;/summary&gt;
          static void Main()
          {
              MyService service = new MyService();
              _servicesToRun.Add(service);
  
              if (Environment.UserInteractive)
              {
                  _servicesToRun.ToArray().LoadServices();
              }
              else
              {
                  ServiceBase.Run(_servicesToRun.ToArray());
              }
          }
      }
  }
  </code></pre>
  
  <p>Then, I receive the following exception when debugging, on the _servicesToRun.ToArray().LoadServices() line:</p>
  
  <pre><code>System.AggregateException was unhandled
    HResult=-2146233088
    Message=One or more errors occurred.
    Source=mscorlib
    StackTrace:
         at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
         at System.Threading.Tasks.Task.Wait()
         at ServiceProcess.Helpers.ServiceRunner.LoadServices(IEnumerable`1 services)
         at EnvisionWatchdog.Program.Main() in c:\DevProjects\Data  Service\DataService\EnvisionWatchdog\Program.cs:line 26
         at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
         at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
         at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
         at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
         at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
         at System.Threading.ThreadHelper.ThreadStart()
    InnerException: System.Windows.Markup.XamlParseException
         HResult=-2146233087
         Message=Set property 'System.Windows.ResourceDictionary.DeferrableContent' threw an exception.
         Source=PresentationFramework
         LineNumber=0
         LinePosition=0
         StackTrace:
              at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
              at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
              at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
              at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
             at ServiceProcess.Helpers.App.InitializeComponent()
              at ServiceProcess.Helpers.ServiceRunner.&lt;&gt;c__DisplayClass5.&lt;LoadServices&gt;b__1()
              at System.Threading.Tasks.Task.Execute()
         InnerException: System.NotImplementedException
              HResult=-2147467263
              Message=The method or operation is not implemented.
              Source=PresentationFramework
              StackTrace:
                   at System.Windows.Baml2006.Baml2006SchemaContext.ResolveBamlType(BamlType bamlType, Int16 typeId)
                   at System.Windows.Baml2006.Baml2006SchemaContext.GetXamlType(Int16 typeId)
                   at System.Windows.Baml2006.Baml2006Reader.Process_ConstructorParameterType()
                   at System.Windows.Baml2006.Baml2006Reader.Process_OneBamlRecord()
                   at System.Windows.Baml2006.Baml2006Reader.ReadKeys()
                   at System.Windows.ResourceDictionary.SetDeferrableContent(DeferrableContent deferrableContent)
                   at System.Windows.Baml2006.WpfSharedBamlSchemaContext.&lt;Create_BamlProperty_ResourceDictionary_DeferrableContent&gt;b__168(Object target, Object value)
                   at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(Object inst, XamlMember property, Object value)
              InnerException: 
  </code></pre>
  
  <p>The odd thing is, the application is a windows service that does not contain any WPF code anywhere.  Does anyone have any suggestions?  TIA.</p>