|
|
Debugging WPF assemblies failing to extract or insert BAML resources |
SolutionCATALYST 2021During insertion or extraction of WPF assemblies, some exceptions can be thrown when CATALYST tries to parse or write the BAML. To record the debug information generated by the .NET framework, create DotNetDebug\dotnetdebug.txt folder and file in the Public folder C:\Users\Public\Alchemy Software\Catalyst 2021 While the file is already present, any debug information will be appended Important Note: A restart of Catalyst will be needed after creating the debug file. Each error output will be appended to the dotnetdebug.txt file. It may be necessary to delete old results for clarity while troubleshooting a current insertion or extraction error, and the file may become large over time.
CATALYST 12 and 2019While inserting or extracting assemblies in Catalyst, you encounter an exception error listed in the Results window. The difficulty is that the error does not give specific information to troubleshoot with. Using a debug log file, detailed information generated by the Framework can be captured and reviewed to help identify what needs correcting.
Adding a log file to the relevant folder will track detailed output of the exception triggered. Create an empty text file called wpf_debug.txt in the following location:
Important Note: A restart of Catalyst will be needed after creating the debug file. Each error output will be appended to the wpf_debug.txt file. It may be necessary to delete old results for clarity while troubleshooting a current insertion or extraction error.
ExampleThis is the output of a problematic extraction in the results window: The output in the wpf_debug.txt file would have further information helpful to debug the extraction issue: **** Exception encountered extracting: ControlTechniques.Comms.UI.Common.g.resources:views/devicediscoverycommandpanelview.baml System.IO.FileNotFoundException: Could not load file or assembly 'ControlTechniques.Common.WPFCustomControls, Version=1.7.1.14147, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. File name: 'ControlTechniques.Common.WPFCustomControls, Version=1.7.1.14147, Culture=neutral, PublicKeyToken=null' at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(String assemblyString) at System.Windows.Markup.BamlReader.ReadAssemblyInfoRecord() at System.Windows.Markup.BamlReader.ReadNextRecord() at System.Windows.Markup.BamlReader.Read() at MS.Internal.Globalization.BamlResourceDeserializer.LoadBamlImp(Stream bamlSteam) at System.Windows.Markup.Localizer.BamlLocalizer..ctor(Stream source, BamlLocalizabilityResolver resolver, TextReader comments) at CatAlWpf.ResourceGenerator.a(Stream A_0, Stream& A_1, BamlLocalizationDictionary A_2, Boolean& A_3, String& A_4) WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. End of Exception in: ControlTechniques.Comms.UI.Common.g.resources:views/devicediscoverycommandpanelview.baml****
The output is very useful in identifying the problematic BAML resource. and can be investigated.
Common errorsThe following xmlns web definitions should be avoided has it causes issues. Although it looks like a URL this definition is actually a GUID; it doesn’t point to an actual Internet web/service or location. xmlns:wpfCustomControls="https://schemas.controltechniques.com/winfx/xaml/wpfcontrols" These GUIDs are registered in the local system (machine) when the corresponding DLL is registered. In the above example, the “URL” would have been registered on the machine the TTK was created on. The GUID was available locally once ControlTechniques.Common.WPFCustomControls.dll was registered on the machine (or inserted in Catalyst). When attempting to extract the assembly on a machine that doesn't have the URL (GUID) registered, the system doesn’t have the info to link the namespace wpfCustomControls to the assembly. The solution is to explicitly reference xmlns:wpfCustomControls="clr-namespace:ControlTechniques.UICommon.WPFCustomControls;assembly=ControlTechniques.Common.WPFCustomControls" Here are examples of explicit xmlns references which are suitable: <ResourceDictionary x:Uid="ResourceDictionary_1" xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml" xmlns:ic="clr-namespace:ControlTechniques.Comms.UI.Helpers;assembly=ControlTechniques.Comms.UI.Common,Version=2.4.1.2,Culture=neutral,PublicKeyToken=null" xmlns:btvc="clr-namespace:ControlTechniques.UICommon.WPFCustomControls.Converters;assembly=ControlTechniques.Common.WPFCustomControls" xmlns:ds="clr-namespace:ControlTechniques.Services.Discovery;assembly=ControlTechniques.Services.Contracts">
Related topicsBest practices for developing localizable .NET applications Localizing .NET framework applications
Products or Versions Affected
|