.NET application cannot start and receive XamlParseException

前端 未结 14 2455
小鲜肉
小鲜肉 2020-11-28 08:47

I wrote an app that can install and work on my development PC (a Window 7).

  • Development Environment: Window 7, VS2010 WPF C# with both .NET 4
相关标签:
14条回答
  • 2020-11-28 09:13

    XamlParseException is the generic error that happens when there is a problem at application start. I suggest you modify you application startup code to trace what's really going on and get, not only the XamlParseException, but also the inner exception(s) which should help you determine the root of the problem. Here is an example:

    namespace WpfApplication1
    {
        /// <summary>
        /// Interaction logic for App.xaml
        /// </summary>
        public partial class App : Application
        {
            protected override void OnStartup(StartupEventArgs e)
            {
                // hook on error before app really starts
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                base.OnStartup(e);
            }
    
            void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
            {
                // put your tracing or logging code here (I put a message box as an example)
                MessageBox.Show(e.ExceptionObject.ToString());
            }
        }
    }
    
    0 讨论(0)
  • 2020-11-28 09:13

    For starters, you'd actually have better luck if you built on VS2010 .. but actually targeted for a lower version of .Net (3.5, or even 2.0).

    It would definitely be helpful if you post a bit of code.

    Make sure you've copied all the necessary files for your application (app.config, etc).

    This link sounds similar:

    .NET 4 Program written/compiled on Windows 7 machine won't run on XP

    And it points to these excellent troubleshooting tips:

    Using Fusion Log Viewer

    0 讨论(0)
  • 2020-11-28 09:16

    Usually what I do is put log files in between processes so I know the flow of my program.

    If this is a console application, put Console.WriteLine(some string) and then you can put Console.ReadLine() at the end to pause the execution of your program.

    0 讨论(0)
  • 2020-11-28 09:16

    Came across a similar problem recently. The problem I had is on windows 7, I was using .ico (icon files). But there is no support for these on XP. In your application, if you are using any icon files, try removing them.. see if this solves the issuse.

    0 讨论(0)
  • 2020-11-28 09:18

    In my case, the problem solved when the user installed the same .Net FW version that I was developing for. (I has FW 4.5.1 and user had FW 4.0).

    So, check the FW version:

    http://msdn.microsoft.com/library/hh925568(v=vs.110).aspx

    And install exactly the same before trying again to execute

    0 讨论(0)
  • 2020-11-28 09:19

    I heard that some commented codes affected on execute output file to behavior something like that happened for your app.(specially in VS 2010 not other earlier version) but in other side,last year i was working on a program that in it i used the Dev Component suite. as you know its crack just work in .Net Framework 3.5 and my program platform was .Net Framework 4.same thing happen for your app, happened fro my app.i had to downgrade my platform to 3.5 and its work good.maybe this personal experience help you dude.

    i want to say some thing else,this some errors are not depend on CPU architecture.Dot worry about it.

    good luck. Ali Foroughi

    0 讨论(0)
提交回复
热议问题