[英]I decompiled a dotnet .dll with ILSpy but the xaml files have some issues
I decompiled a.dll with ILSpy and the code looks fine but I have a xaml file which is:我用 ILSpy 反编译了 a.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....
And I have a bunch of errors:我有一堆错误:
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
But if I just remove x:Class="PrinterManager.ShellView"
the errors are gone and it builds and runs fine.但是,如果我只是删除x:Class="PrinterManager.ShellView"
错误就消失了,它可以正常构建和运行。
I'm sure it's a trivial fix but I never coded in C#, I suspect that's some dependency or config issue?我确定这是一个微不足道的修复,但我从未在 C# 中编码,我怀疑这是一些依赖或配置问题?
Sorry can't share the full source for copyright reasons but happy to share a few extra bits if it helps.抱歉,由于版权原因无法分享完整的源代码,但如果有帮助,我们很乐意分享一些额外的内容。
Exported with latest ILSpy stable, c# 10.0 / VS 2022使用最新的 ILSpy 稳定版导出,c# 10.0 / VS 2022
UPDATE: this seems like my issue https://stackoverflow.com/a/25849873/8340761 but I'm not sure what I'm supposed to change?更新:这似乎是我的问题https://stackoverflow.com/a/25849873/8340761但我不确定我应该更改什么?
To fix it I just had to move each.xaml file next to the same file name.cs要修复它,我只需要将每个 .xaml 文件移动到同一个文件名.cs 旁边
This issue was actually fixed in ILSpy 8这个问题实际上已在 ILSpy 8 中修复
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.