Blogs


  • Improving performance of CRM 2016/Dynamics 365 queries in C#


    Previous version of Dynamics CRM (2011, 2013 and 2015) used to have a class called CachedOrganizationService, that was part of the Microsoft.Xrm.Client.dll Assembly. The new SDK for 2016 and Dynamics 365 doesn't come with that assembly anymore and the connection classes has been moved to the Microsoft.Xrm.Tooling.Connector.dll assembly. However, this class doesn't come with the CachedOrganizationService, if you had an application that used that class and you want to upgrade the code to work with the latest SDK 2016 Dynamics 365 assemblies you will need to manage the caching manually, here is a sample way you can use to improve the queries performance executed by the RetrieveMultiple method of the IOrganizationService interface that is part of the Microsoft.Xrm.Sdk

    private MemoryCache _objectCache = null;
    public EntityCollection RetrieveMultipleCached(Microsoft.Xrm.Sdk.Query.QueryExpression myQueryExpression)
    {
        EntityCollection entityCol = null;
        ObjectCache cache = MemoryCache.Default;
        if (cache.Contains(myQueryExpression.Serialize()))
        {
            entityCol = (EntityCollection)cache[myQueryExpression.Serialize()];
        }
        else
        {
            Microsoft.Xrm.Tooling.Connector.CrmServiceClient conn = new
    Microsoft.Xrm.Tooling.Connector.CrmServiceClient(ConfigurationManager.ConnectionStrings["Xrm"].ConnectionString);
            crmService = (IOrganizationService)conn.OrganizationServiceProxy;
            entityCol = crmService.RetrieveMultiple(myQueryExpression);
            cache.Add(myQueryExpression.Serialize(), entityCol, DateTime.Now.AddDays(30));
        }
        return entityCol;
    }

    You need to be very careful when you use this method as in the case the data changes frequently this way is not recommended, in case you know something changes in the entity data you can invalidate the cache by using a plugin.

    To invalidate the cache you will need to manually remove the items as follows

    foreach (var element in MemoryCache.Default)
    {
    MemoryCache.Default.Remove(element.Key);
    }

    Other recommendations include making the connection object static so you don't need to create the CrmServiceClient on every request.

    Enjoy!


    Continue reading...



  • No Report snapshots created in Dynamics CRM 2015


    If you try to schedule a Report in Dynamics CRM 2015 that uses the FetchXML data source type, this is for example any report you can create using the Report Wizard you will notice there are no Report Snapshots created ever.


     

    Looking at the Reporting Services logs located at C:\Program Files\Microsoft SQL Server\MSRS12.MSSQLSERVER\Reporting Services\LogFiles I found the following exception

    processing!WindowsService_0!1924!01/06/2016-15:40:35:: e ERROR: Failed to load expression host assembly. Details: Could not load file or assembly 'Microsoft.Crm.Reporting.RdlHelper, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
    System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Crm.Reporting.RdlHelper, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
    File name: 'Microsoft.Crm.Reporting.RdlHelper, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
    at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
    at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
    at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
    at System.Reflection.Assembly.Load(String assemblyString)
    at Microsoft.ReportingServices.RdlExpressions.ReportRuntime.ExpressionHostLoader.<>c__DisplayClass27.<LoadExprHostIntoCurrentAppDomain>b__25()
    at Microsoft.ReportingServices.Diagnostics.RevertImpersonationContext.<>c__DisplayClass4.<RunFromRestrictedCasContext>b__3(Object state)
    at System.Security.SecurityContext.runTryCode(Object userData)
    at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
    at System.Security.SecurityContext.Run(SecurityContext securityContext, ContextCallback callback, Object state)
    at Microsoft.ReportingServices.Diagnostics.RevertImpersonationContext.RunFromRestrictedCasContext(ContextBody callback)
    at Microsoft.ReportingServices.RdlExpressions.ReportRuntime.ExpressionHostLoader.LoadExprHostIntoCurrentAppDomain(Byte[] exprHostBytes, String exprHostAssemblyName, Evidence evidence, Boolean includeParameters, Boolean parametersOnly, OnDemandObjectModel objectModel, List`1 codeModules)
    at Microsoft.ReportingServices.RdlExpressions.ReportRuntime.LoadCompiledCode(IExpressionHostAssemblyHolder expressionHostAssemblyHolder, Boolean includeParameters, Boolean parametersOnly, ObjectModelImpl reportObjectModel, ReportRuntimeSetup runtimeSetup)

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

    The Solution

    Edit the ReportingServicesService.exe.config file that is located in the C:\Program Files\Microsoft SQL Server\MSRS12.MSSQLSERVER\Reporting Services\ReportServer\bin folder

    And add the following lines right before the closing tag </assemblyBinding>

    <dependentAssembly>
    <assemblyIdentity name="Microsoft.Crm.Reporting.RdlHelper" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="5.0.0.0" newVersion="7.0.0.0" />
    <bindingRedirect oldVersion="6.0.0.0" newVersion="7.0.0.0" />
    </dependentAssembly>

     The file should look as follows where the new lines added are highlighted in yellow

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        ….
        ….
    <dependentAssembly>
    <assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
    <bindingRedirect oldVersion="10.0.0.0" newVersion="12.0.0.0" />
    <bindingRedirect oldVersion="11.0.0.0" newVersion="12.0.0.0" />
    </dependentAssembly>

    <dependentAssembly>
    <assemblyIdentity name="Microsoft.Crm.Reporting.RdlHelper" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="5.0.0.0" newVersion="7.0.0.0" />
    <bindingRedirect oldVersion="6.0.0.0" newVersion="7.0.0.0" />
    </dependentAssembly>

    </assemblyBinding>
    <gcServer enabled="true" />
    </runtime>
    <startup>
    <supportedRuntime version="v2.0.50727"/>
    </startup>
    </configuration>

    Save the file

    Restart the Reporting Services

    That's it, that should fix the problem


    Continue reading...



  • Microsoft Dynamics CRM 2011 Reporting for $5???


    Yes, for limited period of time you can get my book Microsoft Dynamics CRM 2011 Reporting at a lower price than a Big Mac.

    Notice that even the book was written for the 2011 version of Dynamics CRM, the next versions 2013/2015 and also 2016 had made no changes to the reporting content that was written on that book, so most of the content of the book still applies to all versions of CRM since 2011 to 2016.

    This is your time to order https://www.packtpub.com/application-development/microsoft-dynamics-crm-2011-reporting


    Continue reading...



  • Dynamics CRM 2016 Is Here


    CRM 2016 on-premises is now available for download for MSDN subscribers

    Try CRM 2016 Online for 30 days using the following link

    https://portal.office.com/partner/partnersignup.aspx?type=Trial&id=32fe301a-b691-4bbb-b30b-6343848d0ffc&msppid=585256

    You can download the CRM 2016 SDK from this link

    To read more about the new features you can read this post

    News about the CRM 2016 client for outlook can be read on this post

    Read more about the new Knowledge Management capabilities


    Continue reading...



  • How to teach your kid to be a coder like you


    I could not think another best way to teach my kids to code in a way they would not feel boring in the way to learn.

    The following page https://code.org/mc will teach them with their favorite game Minecraft the basics of code programing.

    I hope this initiative helps to grow our great community of software developers in a world full of computers and devices waiting for us to tell them what to do.

    Happy kids coding!


    Continue reading...



  • Error updating Microsoft Dynamics CRM 2015 0.1


    ​When I tried to update my Microsoft Dynamics CRM 2015 (DB 7.0.03543) to the 0.1 version (DB 7.0.1.129) it came with this error at the DB update:



    Info| Database update install failed for orgId = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. Continuing with other orgs. Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Data.SqlClient.SqlException: The current transaction cannot be committed and cannot support operations that write to the log file. Roll back the transaction. Uncommittable transaction is detected at the end of the batch. The transaction is rolled back. at Microsoft.Crm.Metadata.IndexAndConstraintManagementService.RecreateIndexesInternal(Dictionary`2 indexesToRecreate, IIndexMetadataProvider metadata, ISqlExecutionContext sqlContext) at Microsoft.Crm.Metadata.IndexAndConstraintManagementService.RecreateIndexes(IIndexMetadataProvider metadata, ISqlExecutionContext sqlContext, Func`2 recreateIndex) at Microsoft.Crm.Setup.IndexAndConstraintUpgradeService.RestoreIndexesAndConstraintsInternal(IIndexMetadataProvider metadata, ISqlExecutionContext sqlContext, Func`2 recreateIndex) at Microsoft.Crm.Setup.MetadataPatchService.ProcessIndexDiffs(IIndexDiffManager indexDiffManager, ISqlExecutionContext context, HashSet`1 newEntities) at Microsoft.Crm.Setup.MetadataPatchService.ProcessDiffSet(MetadataPatchDiffSet diffSet, Int32 lcid, ExecutionContext context) at Microsoft.Crm.Setup.MetadataPatchService.ProcessMetadataDiffFile(String targetVersion, ExecutionContext context) at Microsoft.Crm.Setup.DiffBuilder.UpdateMetadata(String targetVersion) --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) at Microsoft.Crm.Setup.Database.DllMethodAction.Execute(Guid organizationId) at Microsoft.Crm.Setup.Database.DatabaseInstaller.ExecuteReleases(ReleaseInfo releaseInfo, Boolean isInstall) at Microsoft.Crm.Setup.Database.DatabaseInstaller.Install(Int32 languageCode, String configurationFilePath, Boolean upgradeDatabase, Boolean isInstall)

    The solution

    1. Make a backup of the file MetadataDiffs.xml from “C:\Program Files\Microsoft Dynamics CRM\Setup\Serviceability\Latest\Actions_Org\Install”
    2. Open the file MetadataDiffs.xml from “C:\Program Files\Microsoft Dynamics CRM\Setup\Serviceability\Latest\Actions_Org\Install”
    3. Remove the entry about the index “cndx_BusinessDataLocalizedLabel”. This is found at the very end of the file:

    <index name="cndx_BusinessDataLocalizedLabel">
         <entityid>4ba1569e-3c9c-4d9f-99ea-b61fb08d7f97</entityid>
         <isclustered>1</isclustered>
         <isunique>1</isunique>
         <indextype>6</indextype>
         <isprimarykey>0</isprimarykey>
         <attributes>
              <attribute attributeid="d88e1df3-b5b3-42f3-9ffa-007f22951dd4" issystemmanaged="1" order="0" />
              <attribute attributeid="bb23d3c8-8d18-40d3-9519-66101a8cae34" issystemmanaged="1" order="1"/>
              <attribute attributeid="976e1053-5faa-4c3f-be6e-669acfec9d5a" issystemmanaged="1" order="2" />
              <attribute attributeid="e81341c4-4d4a-4977-98eb-6597fcde2cc4" issystemmanaged="1" order="3" />
         </attributes>
    </index>


    4.Close Deployment Manager
    5. Start Deployment Manager
    6. Start the organization update from Deployment manager.
    7. Run the following query on the organization DB to manually recreate the index.

    IF EXISTS (SELECT * FROM sys.indexes WHERE name = 'cndx_BusinessDataLocalizedLabel' AND OBJECT_NAME(object_id) = 'BusinessDataLocalizedLabelBase') DROP INDEX [cndx_BusinessDataLocalizedLabel] ON [BusinessDataLocalizedLabelBase];
    IF NOT EXISTS (SELECT * FROM sys.indexes WHERE NAME = 'cndx_BusinessDataLocalizedLabel' AND OBJECT_NAME(object_id) = 'BusinessDataLocalizedLabelBase')
    BEGIN TRY
    CREATE UNIQUE CLUSTERED INDEX [cndx_BusinessDataLocalizedLabel] ON [BusinessDataLocalizedLabelBase]([ObjectId] ASC, [ObjectIdTypeCode] ASC, [ObjectColumnNumber] ASC, [LanguageId] ASC) WITH (FILLFACTOR = 80, MAXDOP = 4, SORT_IN_TEMPDB = ON, ONLINE = ON)
    END TRY
    BEGIN CATCH
    CREATE UNIQUE CLUSTERED INDEX [cndx_BusinessDataLocalizedLabel] ON [BusinessDataLocalizedLabelBase]([ObjectId] ASC, [ObjectIdTypeCode] ASC, [ObjectColumnNumber] ASC, [LanguageId] ASC) WITH (FILLFACTOR = 80, MAXDOP = 4, SORT_IN_TEMPDB = ON)
    END CATCH

    8. Restore the file MetadataDiffs.xml to its original state using the backup taken at step 1.
    And with this the CRM 2015 version will be 7.0.1.129.

    Original source:

    http://www.vogelgesang-consulting.de/content/update-01-microsoft-dynamics-crm-2015

    Enjoy it!

    Continue reading...



  • Checking CRM rollup versions for Dynamic CRM all versions


    Several times you will want to know what version of rollup update you have installed in your CRM 4.0, CRM 2011, 2013 or 2015.

    This blog has the right information and updated with all the most updated rollup versions available ever!

    http://blogs.msdn.com/b/crminthefield/archive/2012/01/12/microsoft-dynamics-crm-4-0-and-2011-update-rollup-release-dates-build-numbers-and-collateral.aspx


    Continue reading...



  • CRM 2013 Update Rollup 2 for Service Pack 1 now available


    Microsoft released a new Update Rollup 2 for Microsoft Dynamics CRM 2013 Service Pack 1, it can be downloaded from

    http://www.microsoft.com/en-us/download/details.aspx?id=45518

    To see more details about what this rollup update covers click on this link

    https://support.microsoft.com/en-us/kb/2963850/


    Continue reading...



  • Dynamics CRM 2015 is here


    Dynamics CRM 2015 is ready and there are different ways to try it

    For people without infrastructure the quickest way to start using Dynamics CRM 2015 is with the On Line version

    You can try the online version by clicking on this link that will create a trial CRM 2015 Online

    https://portal.microsoftonline.com/partner/partnersignup.aspx?type=Trial&id=c71f8e19-8af8-4578-82a0-6b1dc9e55e17&msppid=585256

    For people with enough infrastructure and want to have everything running onsite

    You can download the on-premises version from here

    http://www.microsoft.com/en-us/download/details.aspx?id=45012

    If you want to start developing customization you can download the Dynamics CRM 2015 SDK from here

    http://www.microsoft.com/en-us/download/details.aspx?id=44567

    If you need any assistance don't hesitate to contact us, remember we are experts in Dynamics CRM 2015.


    Continue reading...



  • CRM 2011 Rollup Update 18 now available


    Microsoft released a new Rollup Update (18). It can be downloaded from

    http://www.microsoft.com/en-us/download/details.aspx?id=44265

    To see more details about what this rollup update covers click on this link

    https://support.microsoft.com/en-us/kb/2958724/


    Continue reading...