C# xamlparseexception未处理我能做什么

C# xamlparseexception未处理我能做什么,c#,xaml,exception,C#,Xaml,Exception,当我运行我的应用程序时,我有此异常 Cannot create instance of 'MainWindow' defined in assembly 'MediaTransferTester, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an invocation. Error in markup file 'MainWindow.xam

当我运行我的应用程序时,我有此异常

Cannot create instance of 'MainWindow' defined in assembly 'MediaTransferTester, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an invocation.  Error in markup file 'MainWindow.xaml' Line 1 Position 9.
这是我的xaml代码

<Window x:Class="MediaTransferTester.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow"
        Width="878"
        Height="588">
    <Grid Width="853" Height="525">
        <GroupBox Name="groupBox1"
                  Width="504"
                  Margin="12,12,0,316"
                  HorizontalAlignment="Left"
                  Header="EndPoint Config">

            <Grid Width="468" Height="139">
                <Label Name="label1"
                       Width="108"
                       Height="28"
                       Margin="6,12,0,0"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Top"
                       Content="Loal IPs" />
                <Label Name="label2"
                       Width="108"
                       Height="28"
                       Margin="6,46,0,0"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Top"
                       Content="Remote IP" />
                <Label Name="label3"
                       Width="58"
                       Margin="183,12,0,116"
                       HorizontalAlignment="Left"
                       Content="RTP Port" />
                <Label Name="label4"
                       Width="58"
                       Height="28"
                       Margin="183,47,0,0"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Top"
                       Content="RTP Port" />
                <Label Name="label5"
                       Height="28"
                       Margin="6,84,0,0"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Top"
                       Content="TransportType" />
                <RadioButton Name="rbUDP"
                             Height="16"
                             Margin="112,89,0,0"
                             HorizontalAlignment="Left"
                             VerticalAlignment="Top"
                             Content="UDP"
                             GroupName="TransportType"
                             IsChecked="True" />
                <RadioButton Name="rbMSTP"
                             Height="16"
                             Margin="165,89,0,0"
                             HorizontalAlignment="Left"
                             VerticalAlignment="Top"
                             Content="MSTP"
                             GroupName="TransportType" />
                <RadioButton Name="rbTCPConnect"
                             Height="16"
                             Margin="226,89,0,0"
                             HorizontalAlignment="Left"
                             VerticalAlignment="Top"
                             Content="TCP Connect"
                             GroupName="TransportType" />
                <RadioButton Name="rbTcpListen"
                             Width="76"
                             Height="16"
                             Margin="317,89,0,0"
                             HorizontalAlignment="Left"
                             VerticalAlignment="Top"
                             Content="TCP Listen"
                             GroupName="TransportType" />
                <ListBox Name="listBoxEndPointAddress"
                         Width="102"
                         Height="37"
                         Margin="75,11,0,0"
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         ScrollViewer.HorizontalScrollBarVisibility="Auto"
                         ScrollViewer.VerticalScrollBarVisibility="Visible" />
                <TextBox Name="TBRemoteEndpointIP"
                         Width="102"
                         Height="23"
                         Margin="75,52,0,0"
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         LostFocus="TBRemoteEndpointIP_LostFocus" />
                <TextBox Name="LocalrtpPort"
                         Width="38"
                         Height="23"
                         Margin="247,12,0,0"
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         LostFocus="LocalrtpPort_LostFocus"
                         MaxLength="4" />
                <TextBox Name="RemotertpPort"
                         Width="38"
                         Height="23"
                         Margin="247,46,0,0"
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         LostFocus="RemotertpPort_LostFocus"
                         MaxLength="4" />
                <TextBox Name="localTcpPort"
                         Width="37"
                         Height="23"
                         Margin="0,12,75,0"
                         HorizontalAlignment="Right"
                         VerticalAlignment="Top"
                         LostFocus="localTcpPort_LostFocus"
                         MaxLength="4" />
                <TextBox Name="RemoteTcpPort"
                         Width="37"
                         Height="23"
                         Margin="356,46,0,0"
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         LostFocus="RemoteTcpPort_LostFocus"
                         MaxLength="4" />
                <Label Name="label9"
                       Width="57"
                       Margin="291,11,0,117"
                       HorizontalAlignment="Left"
                       Content="TCP Port" />
                <Label Name="label11"
                       Width="57"
                       Height="28"
                       Margin="291,49,0,0"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Top"
                       Content="TCP Port" />
            </Grid>

        </GroupBox>
        <GroupBox Name="groupBox2"
                  Width="504"
                  Height="269"
                  Margin="12,215,0,0"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Top"
                  Header="AudioConfig">
            <Grid Width="486"
                  Height="245"
                  HorizontalAlignment="Stretch"
                  VerticalAlignment="Stretch">
                <Label Name="label6"
                       Width="90"
                       Height="28"
                       Margin="15,30,0,0"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Top"
                       Content="Source Devices" />
                <Label Name="label7"
                       Width="108"
                       Height="28"
                       Margin="15,89,0,0"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Top"
                       Content="Sink Devices" />
                <Label Name="label10"
                       Height="28"
                       Margin="15,150,0,0"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Top"
                       Content="Send Audio Codecs" />
                <ListBox Name="SourceDeviceList"
                         Width="229"
                         Height="52"
                         Margin="150,6,0,0"
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         ScrollViewer.HorizontalScrollBarVisibility="Auto"
                         ScrollViewer.VerticalScrollBarVisibility="Visible" />
                <ListBox Name="SinkDeviceList"
                         Width="229"
                         Height="53"
                         Margin="150,64,0,0"
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         ScrollViewer.HorizontalScrollBarVisibility="Auto"
                         ScrollViewer.VerticalScrollBarVisibility="Visible" />
                <Label Name="label8"
                       Width="122"
                       Height="28"
                       Margin="15,211,0,0"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Top"
                       Content="Receive Audio Codecs" />
                <ListBox Name="SendCodecsNamelistBox"
                         Width="229"
                         Height="55"
                         Margin="150,123,0,0"
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         ScrollViewer.HorizontalScrollBarVisibility="Auto"
                         ScrollViewer.VerticalScrollBarVisibility="Visible" />
                <ListBox Name="ReceiveCodecsNamelistBox"
                         Width="229"
                         Height="56"
                         Margin="150,183,0,0"
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         ScrollViewer.HorizontalScrollBarVisibility="Auto"
                         ScrollViewer.VerticalScrollBarVisibility="Visible" />
            </Grid>
        </GroupBox>

        <Button Name="btnStartSend"
                Width="75"
                Height="23"
                Margin="12,490,0,0"
                HorizontalAlignment="Left"
                VerticalAlignment="Top"
                Click="btnStartSend_Click"
                Content="Start Send" />
        <Button Name="btnSaveConfig"
                Width="109"
                Height="23"
                Margin="195,490,0,0"
                HorizontalAlignment="Left"
                VerticalAlignment="Top"
                Click="btnSaveConfig_Click"
                Content="Save Configration" />
        <TextBox Name="StatTextBox"
                 Width="319"
                 Height="461"
                 Margin="522,23,0,0"
                 HorizontalAlignment="Left"
                 VerticalAlignment="Top"
                 Background="Black"
                 FontFamily="Consolas"
                 FontSize="9"
                 Foreground="White"
                 IsEnabled="True"
                 IsReadOnly="True"
                 ScrollViewer.HorizontalScrollBarVisibility="Auto"
                 ScrollViewer.VerticalScrollBarVisibility="Auto" />
        <Button Name="btnStartReceve"
                Width="75"
                Height="23"
                Margin="93,490,0,0"
                HorizontalAlignment="Left"
                VerticalAlignment="Top"
                Click="btnStartReceve_Click"
                Content="Start Receve" />
    </Grid>
</Window>

这是例外详细信息

System.Windows.Markup.XamlParseException未处理 Message=无法创建程序集“MediaTransferTester,版本=1.0.0.0,区域性=中立,PublicKeyToken=null”中定义的“MainWindow”的实例。调用的目标已引发异常。标记文件“MainWindow.xaml”第1行第9位出错。 Source=PresentationFramework 行号=1 LinePosition=9 堆栈跟踪: 位于System.Windows.Markup.XamlParseException.ThroweException(字符串消息、异常innerException、Int32 lineNumber、Int32 linePosition、Uri baseUri、XamlObjectId CurrentXamlObjectId、XamlObjectId ContextXamlObjectId、类型objectType) 位于System.Windows.Markup.XamlParseException.ThroweException(ParserContext ParserContext、Int32 lineNumber、Int32 linePosition、字符串消息、异常innerException) 位于System.Windows.Markup.BamlRecordReader.ThroweExceptionWithLine(字符串消息,异常innerException) 位于System.Windows.Markup.BamlRecordReader.CreateInstanceFromType(类型类型,Int16类型ID,布尔throwOnFail) 位于System.Windows.Markup.BamlRecordReader.GetElementAndFlags(BamlElementStartRecord BamlElementStartRecord、对象和元素、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(布尔单记录) 位于System.Windows.Markup.TreeBuilderBamlTranslator.ParseFragment()处 在System.Windows.Markup.TreeBuilder.Parse()中 位于System.Windows.Markup.XamlReader.LoadBaml(Stream-Stream,ParserContext-ParserContext,Object-parent,Boolean-closeStream) 在System.Windows.Application.LoadBamlStreamWithSyncInfo(流,ParserContext pc) 位于System.Windows.Application.LoadComponent(Uri resourceLocator,布尔bSkipJournaledProperties) 在System.Windows.Application.DoStartup()中 在System.Windows.Application.b__0上(对象未使用) 位于System.Windows.Threading.ExceptionWrapper.InternalRealCall(委托回调、对象参数、布尔isSingleParameter) 位于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(对象用户数据) 在System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode代码、CleanupCode backoutCode、Object userData)中运行 位于System.Threading.ExecutionContext.RunInternal(ExecutionContext ExecutionContext,ContextCallback回调,对象状态) 在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和handled) 在MS.Win32.HwndWrapper.WndProc(IntPtr-hwnd、Int32-msg、IntPtr-wParam、IntPtr-lParam、Boolean和handled) 在MS.Win32.HwndSubclass.DispatcherCallbackOperation(对象o)上 位于System.Windows.Threading.ExceptionWrapper.InternalRealCall(委托回调、对象参数、布尔isSingleParameter) 位于System.Windows.Threading.ExceptionWrapper.TryCatchWhen(对象源、委托回调、对象参数、布尔isSingleParameter、委托catchHandler) 位于System.Windows.Threading.Dispatcher.WrappedInvoke(委托回调、对象参数、布尔isSingleParameter、委托catchHandler) 位于System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority优先级、TimeSpan超时、委托方法、对象参数、布尔isSingleParameter) 位于System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority优先级、委托方法、对象参数) 位于MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd、Int32 msg、IntPtr wParam、IntPtr lParam) 位于MS.Win32.unsafentivemethods.DispatchMessage(MSG&MSG) 位于System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame框架) 在System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame框架)上 在System.Windows.Threading.Dispatcher.Run()中 位于System.Windows.Application.RunDispatcher(对象忽略) 位于System.Windows.Application.RunInternal(窗口) 在System.Windows.Application.Run(窗口)中 在System.Windows.Application.Run()处 在C:\Users\t.said\documents\visual studio 2010\Projects\MediaTransferTester\MediaTransferTester\obj\x86\Debug\App.g.cs中的MediaTransferTester.App.Main()处:第0行 位于System.AppDomain.\u下一个安全组件(A
InnerException: System.NullReferenceException Message=Object reference not set to an instance of an object. Source=MediaTransferTester StackTrace: at MediaTransferTester.MainWindow.RegisterHandlers() in C:\Users\t.said\documents\visual studio 2010\Projects\MediaTransferTester\MediaTransferTester\MainWindow.xaml.cs:line 48 at MediaTransferTester.MainWindow..ctor() in C:\Users\t.said\documents\visual studio 2010\Projects\MediaTransferTester\MediaTransferTester\MainWindow.xaml.cs:line 39 InnerException: