{C# 6.0 and VS 2015 Quick Tip} Coding Superpowers for CRM developers – Part 2

Sometimes there is a long gap between Part 1 and Part 2 of my blog series.

But its just because I want to use the concepts in my projects or POC’s before sharing them.


The Part 1 of this series is here: Click here

Part 2 Goes here, the new features which can benefit you!

The new null conditional operator {?.}:

You can do multiple layer null check in one condition, the below snippet checks EntityCollection is not null

and then checks Entities is not null:

  EntityCollection entityCollection = service.RetrieveMultiple(query);


                            if (entityCollection?.Entities != null)


                                // Processing logic



What’s more you can also do null check and also match conditions , the below snippet checks EntityCollection is not null,

then checks Entities is not null and also matches entity count condition:

EntityCollection entityCollection = service.RetrieveMultiple(query);


                            if (entityCollection?.Entities?.Count > 0)


                                // Processing logic



Nameof Operator:

This operator helps you to get the name of a particular type and can be used for handling in exceptions and tracing:

For example:

var entity = service.Retrieve(“account “, new Guid(“B18DFC86-4776-E511-80FC-3863BB343C90”), new ColumnSet(true));


                    Console.WriteLine(“Var in entity is of type: “ + nameof(entity));

                    Console.WriteLine(“Attribute collection in entity is of type: “ + nameof(entity.Attributes));

Gives the output:


Exception filters:

In your CRM exception handling you can filter by messages now:



                        throw new Exception(“CRM Exception”);


                    catch (InvalidPluginExecutionException ex) when (ex.Message == “CRM Exception”)


                        //control will not come in this catch block


                    catch (Exception ex) when (ex.Message == “CRM Exception”)


                        //control will  come in this catch block


Hope it helps and Happy CRMing!


{Error resolution} Import Solution Error: 0x80044150 in Dynamics CRM 2015

Recently in a project we were getting the following error:


Log file will show following entry:


A little digging told me that this happened as we changed attribute types keeping the same attribute names.


So, next thing was to compare the types, delete the old fields from target environment.

Import the solution back and this time it was successful.

Hope it helps and Happy CRMing!