Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ILSpy 7.2.0.6839-preview4 Failed to start in zh-Hans #2623

Closed
czphoenix opened this issue Feb 8, 2022 · 2 comments · Fixed by #2626
Closed

ILSpy 7.2.0.6839-preview4 Failed to start in zh-Hans #2623

czphoenix opened this issue Feb 8, 2022 · 2 comments · Fixed by #2626
Labels

Comments

@czphoenix
Copy link
Contributor

Steps to reproduce

  1. Set Windows locale to zh-CN
  2. Run program

Error message shown

System.Windows.Markup.XamlParseException: 对类型“ICSharpCode.ILSpy.MainWindow”的构造函数执行符合指定的绑定约束的调用时引发了异常。 ---> System.InvalidOperationException: 序列不包含任何匹配元素
   在 System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
   在 ICSharpCode.ILSpy.MainWindow.InitWindowMenu()
   在 ICSharpCode.ILSpy.MainWindow..ctor()
   --- 内部异常堆栈跟踪的结尾 ---
   在 System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
   在 System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
   在 System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
   在 System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
   在 System.Windows.Application.LoadBamlStreamWithSyncInfo(Stream stream, ParserContext pc)
   在 System.Windows.Application.DoStartup()
   在 System.Windows.Application.<.ctor>b__1_0(Object unused)
   在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

Details

  • Product in use: ILSpy

  • Version in use: 7.2.0.6839-preview4 41c99e4

  • in MainWindow.xaml:

    • MenuItem.Header is Properties.Resources._Window
    • MenuItem.Tag is fixed string "_Window"
  • in MainWindow.xaml.cs InitWindowMenu()
    windowMenuItem looks for one whose MenuItem.Tag equals Properties.Resources._Window

  • in Resources.resx it is true

  • in Resources.zh-Hans.resx it is not

<MenuItem Header="{x:Static properties:Resources._Window}" Tag="_Window" />

var windowMenuItem = mainMenu.Items.OfType<MenuItem>().First(m => (string)m.Tag == Properties.Resources._Window);

@czphoenix czphoenix added the Bug label Feb 8, 2022
@czphoenix
Copy link
Contributor Author

incorrect usage also found in:

var windowMenuItem = mainMenu.Items.OfType<MenuItem>().First(m => (string)m.Tag == Properties.Resources._Window);

it seems the correct way is nameof(Properties.Resources._Window):

var windowMenuItem = Instance.mainMenu.Items.OfType<MenuItem>().First(m => (string)m.Tag == nameof(Properties.Resources._Window));

czphoenix added a commit to czphoenix/ILSpy that referenced this issue Feb 8, 2022
siegfriedpammer added a commit that referenced this issue Feb 8, 2022
#2623 Fix error in start up in zh-Hans
@siegfriedpammer siegfriedpammer linked a pull request Feb 8, 2022 that will close this issue
@christophwille
Copy link
Member

Release amended with 6841 binaries (see note on top https://github.com/icsharpcode/ILSpy/releases/tag/v7.2-preview4)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants