我用 ILSpy 反編譯了一個 .dll,代碼看起來不錯,但我有一個 xaml 檔案,它是:
<Window x:Class="PrinterManager.ShellView" 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:PrinterManager" xmlns:sys="clr-namespace:System;assembly=mscorlib" Title="Printer Manager" Height="450" Width="400" ResizeMode="NoResize" Icon="C:\Program Files (x86)\CENSURED" WindowState="Minimized" ShowInTaskbar="False" Visibility="Hidden">
.....MORE XAML STUFF....
<Style x:Key="btnStyle" TargetType="{x:Type Button}">
....MORE XAML....
我有一堆錯誤:
Severity Code Description Project Path File Line Suppression State
Error CS0102 The type 'ShellView' already contains a definition for '_contentLoaded' PrinterManager C:\Users\PietroConvalle\Documents\DotNetDecompileThingy\source\PrinterManager\obj\Debug\net5.0-windows C:\Users\PietroConvalle\Documents\DotNetDecompileThingy\source\PrinterManager\obj\Debug\net5.0-windows\shellview.g.cs 44 Active
Error CS0111 Type 'ShellView' already defines a member called 'InitializeComponent' with the same parameter types PrinterManager C:\Users\PietroConvalle\Documents\DotNetDecompileThingy\source\PrinterManager\obj\Debug\net5.0-windows C:\Users\PietroConvalle\Documents\DotNetDecompileThingy\source\PrinterManager\obj\Debug\net5.0-windows\shellview.g.cs 51 Active
Error CS0111 Type 'ShellView' already defines a member called 'System.Windows.Markup.IComponentConnector.Connect' with the same parameter types PrinterManager C:\Users\PietroConvalle\Documents\DotNetDecompileThingy\source\PrinterManager\obj\Debug\net5.0-windows C:\Users\PietroConvalle\Documents\DotNetDecompileThingy\source\PrinterManager\obj\Debug\net5.0-windows\shellview.g.cs 71 Active
And many more
但是,如果我只是洗掉x:Class="PrinterManager.ShellView"錯誤就消失了,它會構建并運行良好。
我確定這是一個微不足道的修復,但我從未用 C# 編碼,我懷疑這是一些依賴或配置問題?
抱歉,出于著作權原因無法分享完整的源代碼,但如果有幫助,我們很樂意分享一些額外的內容。
使用最新的 ILSpy 穩定版 c# 10.0 / VS 2022 匯出
更新:這似乎是我的問題https://stackoverflow.com/a/25849873/8340761但我不確定我應該改變什么?
uj5u.com熱心網友回復:
要修復它,我只需將每個 .xaml 檔案移動到相同的檔案名 .cs 旁邊
此問題實際上已在 ILSpy 8 中修復
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/533321.html
