Device Guard - Could not load file or assembly
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 9.6k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
Set connectionId threw an exception.
Could not load file or assembly 'Wpf.Ui, Version=4.0.0.0, Culture=neutral, PublicKeyToken=11f9f5cc97b3ffd6' or one of its dependencies. Your organization used Device Guard to block this app. Contact your support person for more info. (Exception from HRESULT: 0x800711C7)
To Reproduce
Just open the application.
Expected behavior
Fixing exactly what Device Guard is blocking in this library.
Screenshots
OS version
Windows 11 - 10.0.22631.4169
.NET version
.NET Framework 4.8
WPF-UI NuGet version
4.0.0-rc.2
Additional context
Source of the error:
at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at Sucrose.Update.View.MainWindow.InitializeComponent() in E:\\MyProject\\Sucrose\\Pro\\Sucrose\\src\\Update\\Sucrose.Update\\View\\MainWindow.xaml:line 1
at Sucrose.Update.View.MainWindow..ctor(Boolean Silent) in E:\\MyProject\\Sucrose\\Pro\\Sucrose\\src\\Update\\Sucrose.Update\\View\\MainWindow.xaml.cs:line 78
at Sucrose.Update.App.Configure(Boolean Silent) in E:\\MyProject\\Sucrose\\Pro\\Sucrose\\src\\Update\\Sucrose.Update\\App.xaml.cs:line 101
at Sucrose.Update.App.OnStartup(StartupEventArgs e) in E:\\MyProject\\Sucrose\\Pro\\Sucrose\\src\\Update\\Sucrose.Update\\App.xaml.cs:line 137
at System.Windows.Application.<.ctor>b__1_0(Object unused)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at Sucrose.Update.View.MainWindow.System.Windows.Markup.IComponentConnector.Connect(Int32 connectionId, Object target)
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetConnectionId(Object root, Int32 connectionId, Object instance)
The full error is:
{
"HResult": -2146233087,
"Source": "PresentationFramework",
"HelpURL": null,
"Message": "Set connectionId threw an exception.",
"ClassName": "System.Windows.Markup.XamlParseException",
"Data": {
"System.Object": null
},
"FullMessage": "Set connectionId threw an exception. -> Could not load file or assembly 'Wpf.Ui, Version=4.0.0.0, Culture=neutral, PublicKeyToken=11f9f5cc97b3ffd6' or one of its dependencies. Your organization used Device Guard to block this app. Contact your support person for more info. (Exception from HRESULT: 0x800711C7)",
"RawStackTrace": " at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)\r\n at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)\r\n at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)\r\n at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)\r\n at Sucrose.Update.View.MainWindow.InitializeComponent() in E:\\MyProject\\Sucrose\\Pro\\Sucrose\\src\\Update\\Sucrose.Update\\View\\MainWindow.xaml:line 1\r\n at Sucrose.Update.View.MainWindow..ctor(Boolean Silent) in E:\\MyProject\\Sucrose\\Pro\\Sucrose\\src\\Update\\Sucrose.Update\\View\\MainWindow.xaml.cs:line 78\r\n at Sucrose.Update.App.Configure(Boolean Silent) in E:\\MyProject\\Sucrose\\Pro\\Sucrose\\src\\Update\\Sucrose.Update\\App.xaml.cs:line 101\r\n at Sucrose.Update.App.OnStartup(StartupEventArgs e) in E:\\MyProject\\Sucrose\\Pro\\Sucrose\\src\\Update\\Sucrose.Update\\App.xaml.cs:line 137\r\n at System.Windows.Application.<.ctor>b__1_0(Object unused)\r\n at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)\r\n at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)",
"StackTrace": [
{
"Method": "Void RewrapException(System.Exception, System.Xaml.IXamlLineInfo, System.Uri)",
"LineNumber": 0,
"FileName": null,
"ColumnNumber": 0
},
{
"Method": "System.Object Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri)",
"LineNumber": 0,
"FileName": null,
"ColumnNumber": 0
},
{
"Method": "System.Object LoadBaml(System.Xaml.XamlReader, Boolean, System.Object, System.Xaml.Permissions.XamlAccessLevel, System.Uri)",
"LineNumber": 0,
"FileName": null,
"ColumnNumber": 0
},
{
"Method": "System.Object LoadBaml(System.IO.Stream, System.Windows.Markup.ParserContext, System.Object, Boolean)",
"LineNumber": 0,
"FileName": null,
"ColumnNumber": 0
},
{
"Method": "Void InitializeComponent()",
"LineNumber": 1,
"FileName": "E:\\MyProject\\Sucrose\\Pro\\Sucrose\\src\\Update\\Sucrose.Update\\View\\MainWindow.xaml",
"ColumnNumber": 13
},
{
"Method": "Void .ctor(Boolean)",
"LineNumber": 78,
"FileName": "E:\\MyProject\\Sucrose\\Pro\\Sucrose\\src\\Update\\Sucrose.Update\\View\\MainWindow.xaml.cs",
"ColumnNumber": 13
},
{
"Method": "Void Configure(Boolean)",
"LineNumber": 101,
"FileName": "E:\\MyProject\\Sucrose\\Pro\\Sucrose\\src\\Update\\Sucrose.Update\\App.xaml.cs",
"ColumnNumber": 13
},
{
"Method": "Void OnStartup(System.Windows.StartupEventArgs)",
"LineNumber": 137,
"FileName": "E:\\MyProject\\Sucrose\\Pro\\Sucrose\\src\\Update\\Sucrose.Update\\App.xaml.cs",
"ColumnNumber": 17
},
{
"Method": "System.Object <.ctor>b__1_0(System.Object)",
"LineNumber": 0,
"FileName": null,
"ColumnNumber": 0
},
{
"Method": "System.Object InternalRealCall(System.Delegate, System.Object, Int32)",
"LineNumber": 0,
"FileName": null,
"ColumnNumber": 0
},
{
"Method": "System.Object TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)",
"LineNumber": 0,
"FileName": null,
"ColumnNumber": 0
}
],
"InnerException": {
"HResult": -2147020345,
"Source": "Sucrose.Update",
"HelpURL": null,
"Message": "Could not load file or assembly 'Wpf.Ui, Version=4.0.0.0, Culture=neutral, PublicKeyToken=11f9f5cc97b3ffd6' or one of its dependencies. Your organization used Device Guard to block this app. Contact your support person for more info. (Exception from HRESULT: 0x800711C7)",
"ClassName": "System.IO.FileLoadException",
"Data": {},
"FullMessage": "Could not load file or assembly 'Wpf.Ui, Version=4.0.0.0, Culture=neutral, PublicKeyToken=11f9f5cc97b3ffd6' or one of its dependencies. Your organization used Device Guard to block this app. Contact your support person for more info. (Exception from HRESULT: 0x800711C7)",
"RawStackTrace": " at Sucrose.Update.View.MainWindow.System.Windows.Markup.IComponentConnector.Connect(Int32 connectionId, Object target)\r\n at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetConnectionId(Object root, Int32 connectionId, Object instance)",
"StackTrace": [
{
"Method": "Void System.Windows.Markup.IComponentConnector.Connect(Int32, System.Object)",
"LineNumber": 0,
"FileName": null,
"ColumnNumber": 0
},
{
"Method": "Void SetConnectionId(System.Object, Int32, System.Object)",
"LineNumber": 0,
"FileName": null,
"ColumnNumber": 0
}
],
"InnerException": null
}
}
Link to the files mentioned in the error:
https://github.com/Taiizor/Sucrose/blob/develop/src/Update/Sucrose.Update/App.xaml.cs
https://github.com/Taiizor/Sucrose/blob/develop/src/Update/Sucrose.Update/View/MainWindow.xaml
https://github.com/Taiizor/Sucrose/blob/develop/src/Update/Sucrose.Update/View/MainWindow.xaml.cs
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reported startup path in Sucrose.Update/App.xaml.cs, View/MainWindow.xaml, and View/MainWindow.xaml.cs, then inspect how the Wpf.Ui 4.0.0 assembly is loaded. Reproduce the failure on Windows 11 with .NET Framework 4.8 and Device Guard enabled. Done means identifying and resolving the library or packaging condition that Device Guard blocks when MainWindow initializes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100