daryllabar / DLaB.Xrm.XrmToolBoxTools

Plugins for the XrmToolBox
MIT License
75 stars 66 forks source link

Upgrading Early Bound Generator V2 to 2.2024.5.16 breaks the plugin #504

Closed donslattery closed 3 weeks ago

donslattery commented 3 weeks ago

Tool and Version What tool/version is it that you're reporting a bug for? i.e. EarlyBoundGenerator V 2.2024.5.16

Describe the bug When I try to update the plugin, install it from a brand new xrm toolbox installation or otherwise interact with it, I get a string of popup errors from XRM toolbox telling me it can't find several DLLs. I've tried it on windows 10, 11, on an existing install in 10, after reinstalling on 10, on a brand new install in 11. The windows 11 fresh install gave me this error: "Could not load file or assembly 'DLaB.XrmToolBoxCommon, Version=1.0.0.4, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified." and then exited gracefully. On Windows 10,

XRM Toolbox version 1.2023.12.68 Windows 11 version: 22Hs 22621.3007 Windows 10 version: 21H2 19044.3930

To Reproduce Steps to reproduce the behavior:

  1. Open XRM Toolbox
  2. Select the tool library
  3. Type "v2" in the search text box to filter results
  4. click the Install button to begin installation of Early Bound Generator V2
  5. Confirm you want to install 1 tool
  6. 42 individual "Tools not loaded" popups appear with the message : Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified.
  7. The installing Tools dialog reports a success for downloading and Installing the EBG V2 plugin and the close button is available.
  8. Click close.
  9. Select the Tools tab to show installed tools - a message is displayed across the top of the tab page stating "One ore more tools failed to load. Click here to see more details."
  10. Clicking to show more details shows "Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified." once you select the error line in the Tool listbox right below the "These tools dailed to load during tools analysis" section of the screen.

Uninstalling 5.16 and reinstalling EarlyBoundGenerator V 2.2024.5.16 works.

Expected behavior I don't expect errors to appear when trying to open the tool

Screenshots 2024-06-10_07-27-36

Additional context Prior to seeing the update message stating there were updates to the plugin, this worked well.

daryllabar commented 3 weeks ago

Sometimes, someway, some how, (never quite sure why/how) the XTB manages to install the sub folder dlls to the plugins directory, rather than to the appropriate XTB\Plugins\DLaB.EarlyBoundGeneratorV2 directory. It then attempts to load these dlls as XTB plugins, which doesn't work. What I've done in the past shut down the XTB, then sort all of the files in the XTB\Plugins by date, (normally the offending dlls all have the same modified date) and move all of the dlls over to the directory it should have went in: ( XTB\Plugins\DLaB.EarlyBoundGeneratorV2), and then restart the XTB.

Here is a list of all the files that should be in the DLaB.EarlyBoundGeneratorV2 sub directory: image

(You also may find an alphabets folder as well that needs to get moved: image

See if you can follow my albeit poor instructions and see if that resolves your issue.

donslattery commented 3 weeks ago

I see what you're talking about for the install. It looks like it mangled it. This is what I adjusted it to based on what I thought you were saying: image

I'm getting a lock error, though, when the output is trying to generate. Is that a known thing? It looks like it's short-circuiting the process and not generating all the output. As near as I can tell, there are no locks other than the EBG V2 and possibly XTB. the tool has worked flawlessly in the past, though. Downgrading it to .15 does the same thing.

Loading settings from C:\Users\USER_NAME\source\repos\PROJECT\PROJECT.Logic.CRM\Models\EarlyBoundGeneratorV2\Settings.XML
CRM Authentication Type Detected: None
Tracking Generation Event.
Updating Builder Settings
Generating Early Bound Files
Generating ProcessModelInvoker Arguments:
--splitfiles
--outdirectory C:\Users\USER_NAME\source\repos\PROJECT\PROJECT.Logic.CRM\Models\EarlyBoundGeneratorV2
--settingsTemplateFile C:\Users\USER_NAME\source\repos\PROJECT\PROJECT.Logic.CRM\Models\EarlyBoundGeneratorV2\builderSettings.json
Finished Generating ProcessModelInvoker Arguments.
Command line for Cloud generation:
PAC modelbuilder build --outdirectory C:\Users\USER_NAME\source\repos\PROJECT\PROJECT.Logic.CRM\Models\EarlyBoundGeneratorV2 --settingsTemplateFile C:\Users\USER_NAME\source\repos\PROJECT\PROJECT.Logic.CRM\Models\EarlyBoundGeneratorV2\builderSettings.json
[ 0: Information ] - Dataverse Model Builder :  [Version 2.0.0.11]
[ 0: Information ] - © 2022 Microsoft Corporation. All rights reserved
[ 0: Information ] - 
[ 0: Information ] - Begin reading metadata from MetadataProviderService
[ 0: Information ] - Looking for custom extension named DLaB.ModelBuilderExtensions.CodeWriterFilterService,DLaB.ModelBuilderExtensions for 
[ 0: Information ] - Looking for custom extension named DLaB.ModelBuilderExtensions.CodeWriterMessageFilterService,DLaB.ModelBuilderExtensions for 
[ 0: Information ] - Looking for custom extension named DLaB.ModelBuilderExtensions.MetadataProviderService,DLaB.ModelBuilderExtensions for 
[ 0: Information ] - Looking for custom extension named DLaB.ModelBuilderExtensions.MetadataQueryProviderService,DLaB.ModelBuilderExtensions for 
[ 0: Information ] - Looking for custom extension named DLaB.ModelBuilderExtensions.CodeGenerationService,DLaB.ModelBuilderExtensions for 
[ 0: Information ] - Looking for custom extension named DLaB.ModelBuilderExtensions.NamingService,DLaB.ModelBuilderExtensions for 
[ 0: Information ] - Looking for custom extension named DLaB.ModelBuilderExtensions.CustomizeCodeDomService,DLaB.ModelBuilderExtensions for 
[ 0: Information ] - Begin Reading Metadata from Server
[ 0: Information ] - Read 7 Entities - 00:00:00.617
[ 0: Information ] - Read 0 Global OptionSets - 00:00:00.000
[ 0: Information ] - Read 8 SDK Messages - 00:00:02.326
[ 0: Information ] - Completed Reading Metadata from Server - 00:00:03.051
[ 0: Information ] - Completed reading metadata from MetadataProviderService - 00:00:03.079
[ 0: Information ] - Begin Writing Code Files
[ 0: Information ] - Processing 7 Entities
[ 0: Information ] - Wrote 7 Entities - 00:00:00.0565480
[ 0: Information ] - Processing 8 Messages
[ 0: Information ] - Wrote 2 Message(s). Skipped 6 Message(s) - 00:00:00.0102612
[ 0: Information ] - Processing 0 Global OptionSets
[ 0: Information ] - Wrote 0 Global OptionSets - 00:00:00.0000016
System.IO.IOException: The process cannot access the file 'C:\Users\USER_NAME\source\repos\PROJECT\PROJECT.Logic.CRM\Models\Generated\xxxx_PROJECTCourse.cs' because it is being used by another process.
[ 0: Error       ] - Exiting program with exit code 2 due to exception : System.IO.IOException: The process cannot access the file 'C:\Users\USER_NAME\source\repos\PROJECT\PROJECT.Logic.CRM\Models\Generated\xxxx_PROJECTCourse.cs' because it is being used by another process.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)
   at System.IO.File.WriteAllLines(String path, IEnumerable`1 contents, Encoding encoding)
   at DLaB.ModelBuilderExtensions.CustomTextWriter.Dispose(Boolean disposing)
   at System.IO.TextWriter.Dispose()
   at DLaB.ModelBuilderExtensions.PacModelBuilderCodeGenHack.WriteFile(String outputFile, String language, CodeNamespace codenamespace, IServiceProvider serviceProvider, Boolean writeProxyAttrib, Boolean isFileSplit)
   at DLaB.ModelBuilderExtensions.PacModelBuilderCodeGenHack.Write(IOrganizationMetadata organizationMetadata, String language, String outputFile, String outputNamespace, IServiceProvider serviceProvider)
   at DLaB.ModelBuilderExtensions.CodeGenerationService.WriteInternal(IOrganizationMetadata organizationMetadata, String language, String outputFile, String targetNamespace, IServiceProvider services)
   at DLaB.ModelBuilderExtensions.CodeGenerationService.Write(IOrganizationMetadata organizationMetadata, String language, String outputFile, String outputNamespace, IServiceProvider services)
   at Microsoft.PowerPlatform.Dataverse.ModelBuilderLib.ModelBuilder.WriteCode(IOrganizationMetadata organizationMetadata)
   at Microsoft.PowerPlatform.Dataverse.ModelBuilderLib.ModelBuilder.Run()
   at Microsoft.PowerPlatform.Dataverse.ModelBuilderLib.ModelBuilder.Invoke(IOrganizationService serviceClient)
[ 0: Error       ] - ===== DETAIL ======
[ 0: Error       ] - Source : mscorlib
Method  : WinIOError
Date    : 11:50:46 AM
Time    : 6/10/2024
Error   : The process cannot access the file 'C:\Users\USER_NAME\source\repos\PROJECT\PROJECT.Logic.CRM\Models\Generated\xxxx_PROJECTCourse.cs' because it is being used by another process.
Stack Trace : at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)
   at System.IO.File.WriteAllLines(String path, IEnumerable`1 contents, Encoding encoding)
   at DLaB.ModelBuilderExtensions.CustomTextWriter.Dispose(Boolean disposing)
   at System.IO.TextWriter.Dispose()
   at DLaB.ModelBuilderExtensions.PacModelBuilderCodeGenHack.WriteFile(String outputFile, String language, CodeNamespace codenamespace, IServiceProvider serviceProvider, Boolean writeProxyAttrib, Boolean isFileSplit)
   at DLaB.ModelBuilderExtensions.PacModelBuilderCodeGenHack.Write(IOrganizationMetadata organizationMetadata, String language, String outputFile, String outputNamespace, IServiceProvider serviceProvider)
   at DLaB.ModelBuilderExtensions.CodeGenerationService.WriteInternal(IOrganizationMetadata organizationMetadata, String language, String outputFile, String targetNamespace, IServiceProvider services)
   at DLaB.ModelBuilderExtensions.CodeGenerationService.Write(IOrganizationMetadata organizationMetadata, String language, String outputFile, String outputNamespace, IServiceProvider services)
   at Microsoft.PowerPlatform.Dataverse.ModelBuilderLib.ModelBuilder.WriteCode(IOrganizationMetadata organizationMetadata)
   at Microsoft.PowerPlatform.Dataverse.ModelBuilderLib.ModelBuilder.Run()
   at Microsoft.PowerPlatform.Dataverse.ModelBuilderLib.ModelBuilder.Invoke(IOrganizationService serviceClient)
======================================================================================================================

 An error when calling ProcessModelInvoker.Invoke.  Result: 2
Log File:
System.IO.IOException: The process cannot access the file 'C:\Users\USER_NAME\source\repos\PROJECT\PROJECT.Logic.CRM\Models\Generated\xxxx_PROJECTCourse.cs' because it is being used by another process.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)
   at System.IO.File.WriteAllLines(String path, IEnumerable`1 contents, Encoding encoding)
   at DLaB.ModelBuilderExtensions.CustomTextWriter.Dispose(Boolean disposing)
   at System.IO.TextWriter.Dispose()
   at DLaB.ModelBuilderExtensions.PacModelBuilderCodeGenHack.WriteFile(String outputFile, String language, CodeNamespace codenamespace, IServiceProvider serviceProvider, Boolean writeProxyAttrib, Boolean isFileSplit)
   at DLaB.ModelBuilderExtensions.PacModelBuilderCodeGenHack.Write(IOrganizationMetadata organizationMetadata, String language, String outputFile, String outputNamespace, IServiceProvider serviceProvider)
   at DLaB.ModelBuilderExtensions.CodeGenerationService.WriteInternal(IOrganizationMetadata organizationMetadata, String language, String outputFile, String targetNamespace, IServiceProvider services)
   at DLaB.ModelBuilderExtensions.CodeGenerationService.Write(IOrganizationMetadata organizationMetadata, String language, String outputFile, String outputNamespace, IServiceProvider services)
Generation Complete!
daryllabar commented 3 weeks ago

Something is locking the file. Maybe use File Locksmith to unlock it? https://learn.microsoft.com/en-us/windows/powertoys/file-locksmith

Or try turning it off an back on again. (The XTB first, than the computer itself) If it still doesn't work, delete your manifest.json, file the Plugins/EarlyBoundGeneratorV2.dll and the Plugins/EarlyBoundGeneratorV2 folder and try again.

donslattery commented 3 weeks ago

Even after a clean reboot the lock is still happening. Replaced the files, etc. Very strange. The lock only seems to affect the export process then, when you check it after the export, the lock is gone. I've not seen this before. Usually after you compile something, Visual Studio likes to keep locks open but XTB is the only app running. The issue is not present on a VM with Windows 11 and the same version of XTB and EBG so it's clearly an environment thing. I'll try generating to a different location.

daryllabar commented 3 weeks ago

Did you determine the program that's locking it? Any chance you somehow have the older version? I did recently update that code to handle that very error: https://github.com/daryllabar/DLaB.Xrm.XrmToolBoxTools/issues/498

You'd specifically would want to look at the DLaB.ModelBuilderExtensions.dll version: image

donslattery commented 3 weeks ago

My version is the previous version.
image

That was finally it. It looks like it was a combination of some things. When I completely removed the plugin and the supporting directory, then reinstalled, it sorted it out. Something went sideways between the .15 and .16 installs. there were two versions of the files. One in the main plugin directory and the older set in the correct folder structure. After nuking the plugin data for EBG, it looks like it's correct now and working.

THANK YOU for your time. Both for helping me AND all your work on the tool.

donslattery commented 3 weeks ago

Environmental/XTB installation issue that put DLLs out of sync on a failed update. The .16 code works as expected.