Laden...

MainWindow verschieben erzeugt Fehlermeldung: Initializecomponent does not exist in current context"

Erstellt von mankingwwe vor 6 Jahren Letzter Beitrag vor 6 Jahren 3.114 Views
M
mankingwwe Themenstarter:in
39 Beiträge seit 2018
vor 6 Jahren
MainWindow verschieben erzeugt Fehlermeldung: Initializecomponent does not exist in current context"

Hey...
Bin gerade so am verzweifeln es kann doch nicht so schwer sein.
Verschiebe mein MainWindow in einen Order und das erzeugt immer wieder diese Fehlermeldung wie im Titel beschrieben.Habe eigentlich auch alles angepasst.. X( X( X( X(


<Window x:Class="ParkingMeter.Views.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:ParkingMeter.Views"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        
    </Grid>
</Window>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Anleitung.Views.ParkingMeter
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
    }
}

<Application x:Class="ParkingMeter.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:ParkingMeter.Views"
             StartupUri="ParkingMeter.Views.MainWindow.xaml">
    <Application.Resources>
         
    </Application.Resources>
</Application>

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace ParkingMeter
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
    }
}

D
261 Beiträge seit 2015
vor 6 Jahren

Hast du es nach dem Verschieben mit einem Neustart von Visual Studio probiert?

M
mankingwwe Themenstarter:in
39 Beiträge seit 2018
vor 6 Jahren

Ja, aber hilft nichts... 🙁

D
261 Beiträge seit 2015
vor 6 Jahren

Die Namespaces im XAML und im Codebehind sind unterschiedlich.

ParkingMeter.Views.MainWindow
vs.
Anleitung.Views.ParkingMeter.MainWindow

M
mankingwwe Themenstarter:in
39 Beiträge seit 2018
vor 6 Jahren

Unbehandelte Ausnahme: System.IO.IOException: Die Ressource "parkingmeter.views.mainwindow.xaml" kann nicht gefunden werden.
bei MS.Internal.AppModel.ResourcePart.GetStreamCore(FileMode mode, FileAccess access)
bei System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess access)
bei System.IO.Packaging.PackagePart.GetStream()
bei System.Windows.Application.LoadComponent(Uri resourceLocator, Boolean bSkipJournaledProperties)
bei System.Windows.Application.DoStartup()
bei System.Windows.Application.<.ctor>b__1_0(Object unused)
bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
bei System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
bei System.Windows.Threading.DispatcherOperation.InvokeImpl()
bei System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
bei MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bei MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Windows.Threading.DispatcherOperation.Invoke()
bei System.Windows.Threading.Dispatcher.ProcessQueue()
bei System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
bei MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
bei MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
bei System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
bei System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
bei MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
bei MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
bei System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
bei System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
bei System.Windows.Application.RunDispatcher(Object ignore)
bei System.Windows.Application.RunInternal(Window window)
bei System.Windows.Application.Run(Window window)
bei System.Windows.Application.Run()
bei ParkingMeter.App.Main()
The program '[11996] ParkingMeter.exe' has exited with code 0 (0x0).

neue fehlermeldung...

D
261 Beiträge seit 2015
vor 6 Jahren

Wo hast du die Änderungen gemacht?
Kannst du bitte noch mal den Inhalt der XAML- und der Codebehind-Datei vom MainWindow posten.

M
mankingwwe Themenstarter:in
39 Beiträge seit 2018
vor 6 Jahren
<Window x:Class="ParkingMeter.Views.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:ParkingMeter.Views"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        
    </Grid>
</Window>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ParkingMeter.Views
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
    }
}

Danke für die Hilfe..

M
mankingwwe Themenstarter:in
39 Beiträge seit 2018
vor 6 Jahren

Im Code behind ist seit der Änderung auch die Funktion InitializeComponent wieder verfügbar. Scheint also richtig geändert zu sein.

D
261 Beiträge seit 2015
vor 6 Jahren

Ändere mal die Startupuri in der App.xaml auf "Views/MainWindow.xaml".

M
mankingwwe Themenstarter:in
39 Beiträge seit 2018
vor 6 Jahren

Es wurde gelöst. Danke für die Hilfe 😃