daryllabar / DLaB.Xrm.XrmToolBoxTools

Plugins for the XrmToolBox
MIT License
78 stars 70 forks source link

Error on Generating - Query on Entity has exceeded the hard limit of conditions in a single filter (300) #493

Closed aboodh95 closed 6 months ago

aboodh95 commented 7 months ago

Hi,

I'm trying to generate entities for a new client, they have huge number of entities (around 350), but no matter what I did, I keep get an error once I'm trying to generate,

Loading settings from PROJECT_PATH\EGB.xml CRM Authentication Type Detected: None Tracking Generation Event. Updating Builder Settings Generating Early Bound Files Generating ProcessModelInvoker Arguments: --splitfiles --outdirectory PROJECT_PATH --settingsTemplateFile PROJECT_PATH\builderSettings.json Finished Generating ProcessModelInvoker Arguments. Command line for Cloud generation: PAC modelbuilder build --outdirectory PROJECT_PATH --settingsTemplateFile PROJECT_PATH\builderSettings.json [ 0: Information ] - Dataverse Model Builder : [Version 2.0.0.6] [ 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 System.ServiceModel.FaultException1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: Query on Entity has exceeded the hard limit of conditions in a single filter (300). (Fault Detail is equal to Exception details: [ 0: Error ] - Exiting program with exit code 2 due to exception : Exception details: ErrorCode: 0x80044183 Message: Query on Entity has exceeded the hard limit of conditions in a single filter (300). TimeStamp: 2024-04-22T21:01:11.1628840Z

Exception details: ErrorCode: 0x80044183 Message: Query on Entity has exceeded the hard limit of conditions in a single filter (300). TimeStamp: 2024-04-22T21:01:11.1628840Z

[ 0: Error ] - ===== DETAIL ====== [ 0: Error ] - Source : mscorlib Method : HandleReturnMessage Date : 12:01:12 AM Time : 23/04/2024 Error : Query on Entity has exceeded the hard limit of conditions in a single filter (300). Stack Trace : Server stack trace: at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: at Microsoft.Xrm.Tooling.Connector.CrmServiceClient.Execute(OrganizationRequest request) at Microsoft.PowerPlatform.Dataverse.ModelBuilderLib.MetadataProviderQueryService.RetrieveEntities(IOrganizationService service) at Microsoft.PowerPlatform.Dataverse.ModelBuilderLib.SdkMetadataProviderService.LoadMetadata(IServiceProvider service) at DLaB.ModelBuilderExtensions.MetadataProviderService.LoadMetadataInternal(IServiceProvider service) at DLaB.ModelBuilderExtensions.MetadataProviderService.LoadMetadata(IServiceProvider service) 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.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: Query on Entity has exceeded the hard limit of conditions in a single filter (300). (Fault Detail is equal to Exception details: ErrorCode: 0x80044183 Message: Query on Entity has exceeded the hard limit of conditions in a single filter (300). TimeStamp: 2024-04-22T21:01:11.1628840Z

Exception details: ErrorCode: 0x80044183 Message: Query on Entity has exceeded the hard limit of conditions in a single filter (300). TimeStamp: 2024-04-22T21:01:11.1628840Z

). Generation Complete! `

I tried to reduce down the selected entities from 350 to 250, still the error showing.


daryllabar commented 7 months ago

Can you shutdown the XTB, and then replace the Microsoft.PowerPlatofrm.Dataverse.ModelBuilder dll in your XrmToolBox\Plugins\DLaB.EarlyBoundGeneratorV2 folder with this (might want to make a back up first), and try again?

Microsoft.PowerPlatform.Dataverse.ModelBuilderLib.zip

daryllabar commented 7 months ago

@aboodh95 just checking to see if you had a chance to test the dll.

aboodh95 commented 7 months ago

Hi @daryllabar After replacing the dll, i'm getting this error

` System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.PowerPlatform.Dataverse.ModelBuilderLib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.PowerPlatform.Dataverse.ModelBuilderLib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' at DLaB.EarlyBoundGeneratorV2.Logic.Create(IOrganizationService service) at DLaB.EarlyBoundGeneratorV2.EarlyBoundGeneratorPlugin.b__49_0(BackgroundWorker w, DoWorkEventArgs e)

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].

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.PowerPlatform.Dataverse.ModelBuilderLib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.PowerPlatform.Dataverse.ModelBuilderLib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' at DLaB.EarlyBoundGeneratorV2.Logic.Create(IOrganizationService service) at DLaB.EarlyBoundGeneratorV2.EarlyBoundGeneratorPlugin.b__49_0(BackgroundWorker w, DoWorkEventArgs e)

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].

`

daryllabar commented 7 months ago

Stink... I don't think I can build a MS dll and have it get loaded correctly...

daryllabar commented 7 months ago

DLaB.EarlyBoundGeneratorV2.zip Take two, you'll need to replace the DLaB.EarlyBoundGenratorV2.dll with the dll in the folder, and delete the DLaB.EarlyBoundGeneratorV2 folder and replace it with the one in the zip.

aboodh95 commented 7 months ago

Hi, A new error is showing

CRM Authentication Type Detected: None Tracking Generation Event. Updating Builder Settings Generating Early Bound Files System.IO.FileLoadException: Could not load file or assembly 'Microsoft.PowerPlatform.Dataverse.ModelBuilderLib, Version=2.0.0.6, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A) File name: 'Microsoft.PowerPlatform.Dataverse.ModelBuilderLib, Version=2.0.0.6, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ---> System.Security.SecurityException: Strong name validation failed. (Exception from HRESULT: 0x8013141A) The Zone of the assembly that failed was: MyComputer at DLaB.EarlyBoundGeneratorV2.Logic.Create(IOrganizationService service) at DLaB.EarlyBoundGeneratorV2.EarlyBoundGeneratorPlugin.b__49_0(BackgroundWorker w, DoWorkEventArgs e)

System.IO.FileLoadException: Could not load file or assembly 'Microsoft.PowerPlatform.Dataverse.ModelBuilderLib, Version=2.0.0.6, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A) File name: 'Microsoft.PowerPlatform.Dataverse.ModelBuilderLib, Version=2.0.0.6, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ---> System.Security.SecurityException: Strong name validation failed. (Exception from HRESULT: 0x8013141A) The Zone of the assembly that failed was: MyComputer at DLaB.EarlyBoundGeneratorV2.Logic.Create(IOrganizationService service) at DLaB.EarlyBoundGeneratorV2.EarlyBoundGeneratorPlugin.b__49_0(BackgroundWorker w, DoWorkEventArgs e)

daryllabar commented 7 months ago

Interesting, It works on my machine. I'll submit my PR To MS to fix it in the PAC. In the mean time, you could split up the number of entities that you are generating, and run it multiple times as an extremely painful work around?

aboodh95 commented 7 months ago

Hi,

Thanks for the work, I went back to V1 and it did work fine, but I want to share with you another issue regarding this error, the moment the error of 300 limits happens, the tool will stop working for other requests, until I close the app and re-open it, to reproduce it, this is what I did

I connected to the org of client A, they have more than 500 entities, I got the error, I closed the tool. I connected to the org of client B, they have around 40 entities, I got the same error, I checked the XML file, and only 40 entities were selected, I opened Fiddler, and runner the request, the client A entities were showeing in the request, After closing XrmToolBox, everything back to normal

I think it's caching the request in case it didn't succeed, but I just wanted to let you know about it

daryllabar commented 7 months ago

Hmm.. that shouldn't be possible. I'm submitting the PR to MS now for the initial fix, will mark this as completed when I can reference their code, post them building and releasing.