実現したいこと
上手くビルドを成功させたい。
発生している問題・分からないこと
WPFアプリの開発をおこなっているときに、ビルドしようとしたら、このようなエラーが起きて、ビルドに失敗した。ソースコードは一部分。何回やっても同じで、一度も成功していない。
エラーメッセージ
error
11>C:\Users\tazu0\source\repos\WpfApp7\.vs\WpfApp7\obj\WpfApp7\Debug\net8.0-windows\App.g.cs(52,21,52,40): warning CS0108: 'GeneratedApp.InitializeComponent()' は継承されたメンバー 'App.InitializeComponent()' を非表示にします。非表示にする場合は、キーワード new を使用してください。 21>C:\Users\tazu0\source\repos\WpfApp7\WpfApp7\MainWindo.xaml.cs(686,26,686,36): error CS8646: 'IComponentConnector.Connect(int, object)' が複数回、明示的に実装されています。 31>C:\Users\tazu0\source\repos\WpfApp7\WpfApp7\MainWindo.xaml(206,47,206,59): error CS0102: 型 'MainWindow' は既に 'SupportPanel' の定義を含んでいます 41>C:\Users\tazu0\source\repos\WpfApp7\WpfApp7\MainWindo.xaml(207,49,207,57): error CS0102: 型 'MainWindow' は既に 'Support1' の定義を含んでいます 51>C:\Users\tazu0\source\repos\WpfApp7\WpfApp7\MainWindo.xaml(214,49,214,56): error CS0102: 型 'MainWindow' は既に 'MenuBtn' の定義を含んでいます 61>C:\Users\tazu0\source\repos\WpfApp7\WpfApp7\MainWindo.xaml(219,54,219,63): error CS0102: 型 'MainWindow' は既に 'MenuItems' の定義を含んでいます 71>C:\Users\tazu0\source\repos\WpfApp7\WpfApp7\MainWindo.xaml(240,47,240,55): error CS0102: 型 'MainWindow' は既に 'MainGuid' の定義を含んでいます 81>C:\Users\tazu0\source\repos\WpfApp7\.vs\WpfApp7\obj\WpfApp7\Debug\net8.0-windows\MainWindo.g.cs(99,22,99,36): error CS0102: 型 'MainWindow' は既に '_contentLoaded' の定義を含んでいます 91>C:\Users\tazu0\source\repos\WpfApp7\.vs\WpfApp7\obj\WpfApp7\Debug\net8.0-windows\MainWindo.g.cs(106,21,106,40): error CS0111: 型 'MainWindow' は、'InitializeComponent' と呼ばれるメンバーを同じパラメーターの型で既に定義しています 101>C:\Users\tazu0\source\repos\WpfApp7\.vs\WpfApp7\obj\WpfApp7\Debug\net8.0-windows\MainWindo.g.cs(126,56,126,63): error CS0111: 型 'MainWindow' は、'System.Windows.Markup.IComponentConnector.Connect' と呼ばれるメンバーを同じパラメーターの型で既に定義しています 111>C:\Users\tazu0\source\repos\WpfApp7\WpfApp7\MainWindo.xaml.cs(9474,81,9474,85): warning CS8625: null リテラルを null 非許容参照型に変換できません。 121>C:\Users\tazu0\source\repos\WpfApp7\WpfApp7\MainWindo.xaml.cs(9525,84,9525,88): warning CS8625: null リテラルを null 非許容参照型に変換できません。 131>C:\Users\tazu0\source\repos\WpfApp7\WpfApp7\MainWindo.xaml.cs(9590,86,9590,90): warning CS8625: null リテラルを null 非許容参照型に変換できません。 141>プロジェクト "WpfApp7_i2zrwlgq_wpftmp.csproj" のビルドが終了しました -- 失敗。
該当のソースコード
using System; using System.CodeDom.Compiler; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Configuration; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Management; using System.Net; using System.Net.NetworkInformation; using System.Net.Security; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Cryptography.X509Certificates; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Markup; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using System.Windows.Shapes; using System.Windows.Threading; using AppleComponentSupport; using CommonServiceLocator; using Core.Downloader.Business; using Core.Http; using Core.Tracing; using Core.Tracing.Enum; using Core.Tracing.GA4; using Core.Tracing.GA4.Model; using IBackupLibrary.Decription; using iMobie.iDeviceConfig; using LogLib; using Microsoft.Win32; using Module.Base; using Module.Base.Model; using Module.Base.Utilities; using Module.Base.View.DialogWindow; using Module.Base.ViewModel; using Module.Base.ViewModel.DialogWindow; using Module.Base.ViewModel.Module; using Newtonsoft.Json; using Prism; using Prism.Commands; using Prism.Events; //using static Prism.Events.EventBase; using Prism.Ioc; using Prism.Modularity; using Prism.Mvvm; using Prism.Regions; using Prism.Services.Dialogs; using Prism.Unity; using Project.Shell.Controls; using Project.Shell.Model; using Project.Shell.Model.Activate; using Project.Shell.Model.Environment; using Project.Shell.Model.Update; using Project.Shell.Properties; using Project.Shell.Utilities; using Project.Shell.Utilities.NewActivate; using Project.Shell.Utilities.UpdateConfig; using Project.Shell.View; using Project.Shell.View.Window; using Project.Shell.View.Window.Activate; using Project.Shell.View.Window.Activity; using Project.Shell.View.Window.Device; using Project.Shell.ViewModel; using Project.Shell.ViewModel.Window; using Project.Shell.ViewModel.Window.Activate; using Project.Shell.ViewModel.Window.Activity; using Project.Shell.ViewModel.Window.Device; using Project.Structure.SEnum; using Project.Structure.SEvent; using Project.Structure.SEvent.Events; using Project.Structure.SEvent.Events.FunctionButton; using Project.Structure.SPrism; using Resource.Controls; using Resource.Utilities; using Service.iOSSupport; using Service.iOSSupport.DeviceBackup; using Service.iOSSupport.DeviceRestore; using Service.iOSSupport.Model; using Service.RG; using Service.RG.Config; using Service.RG.Model; using UI.Controls; using UI.Controls.Controls; using UI.Controls.Controls.IElement; using UI.Controls.Enum; using Utilities; public partial class MainWindow : CustomWindow, IComponentConnector { internal Grid SupportPanel; internal Button Support1; internal Button MenuBtn; internal ContextMenu MenuItems; internal Grid MainGuid; private bool _contentLoaded; public MainWindow() { InitializeComponent(); EventTool.GetEvent<EventGetSupportPosition>().Subscribe(OnGetSupportPosition); } private void OnGetSupportPosition(Action<Func<Rect>> obj) { obj(delegate { Point point = SupportPanel.TranslatePoint(default(Point), this); return (base.FlowDirection == FlowDirection.LeftToRight) ? new Rect(point.X, point.Y, SupportPanel.ActualWidth, SupportPanel.ActualHeight) : new Rect(base.ActualWidth - point.X, point.Y, SupportPanel.ActualWidth, SupportPanel.ActualHeight); }); } private void CustomWindow_PreviewKeyDown(object sender, KeyEventArgs e) { ((PubSubEvent<KeyEventArgs>)(object)EventTool.GetEvent<EventKeyDown>()).Publish(e); } private void Menu_Click(object sender, RoutedEventArgs e) { MenuItems.PlacementTarget = MenuBtn; MenuItems.Placement = PlacementMode.Custom; ContextMenu menuItems = MenuItems; menuItems.CustomPopupPlacementCallback = (CustomPopupPlacementCallback)Delegate.Remove(menuItems.CustomPopupPlacementCallback, new CustomPopupPlacementCallback(MenuItemCallBack)); ContextMenu menuItems2 = MenuItems; menuItems2.CustomPopupPlacementCallback = (CustomPopupPlacementCallback)Delegate.Combine(menuItems2.CustomPopupPlacementCallback, new CustomPopupPlacementCallback(MenuItemCallBack)); MenuItems.MinWidth = 190.0; MenuItems.IsOpen = false; MenuItems.IsOpen = true; } private CustomPopupPlacement[] MenuItemCallBack(Size popupSize, Size targetSize, Point offset) { CustomPopupPlacement[] array = new CustomPopupPlacement[1]; Point popupPoint = PlacementTool.GetPopupPoint(popupSize, targetSize, PlacementEnum.Bottom, default(Thickness), base.FlowDirection); array[0] = new CustomPopupPlacement(popupPoint, PopupPrimaryAxis.None); return array; } [DebuggerNonUserCode] [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] public void InitializeComponent() { if (!_contentLoaded) { _contentLoaded = true; Uri resourceLocator = new Uri("/AnyUnlock - iPhone Password Unlocker;component/mainwindow.xaml", UriKind.Relative); Application.LoadComponent(this, resourceLocator); } } [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] [DebuggerNonUserCode] [EditorBrowsable(EditorBrowsableState.Never)] void IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { default: _contentLoaded = true; break; case 1: ((MainWindow)target).PreviewKeyDown += CustomWindow_PreviewKeyDown; break; case 2: SupportPanel = (Grid)target; break; case 3: Support1 = (Button)target; break; case 4: MenuBtn = (Button)target; MenuBtn.Click += Menu_Click; break; case 5: MenuItems = (ContextMenu)target; break; case 6: MainGuid = (Grid)target; break; } } }
試したこと・調べたこと
- teratailやGoogle等で検索した
- ソースコードを自分なりに変更した
- 知人に聞いた
- その他
上記の詳細・結果
このエラー文の一部をコピペして調べてみたが、あまり参考になる情報がなかった。obj/などのファイルを消して再ビルドしても、解決しなかった。
補足
環境はVisualstudio2022のVer.17.14.4です。
