Exception: lookupvalue

An attribute in the execute request is of type EntityReference and its entity logical name is incorrect.

Posted in Error, Plugins, Uncategorized | Tagged , , | Leave a comment

Retrieve the text label for an OptionSet value

Here is the implementation I use for a method to get back the text/caption of an OptionSet item.

private  string GetOptionsSetTextOnValue(IOrganizationService service, string entityName, string attributeName, intselectedValue)
RetrieveAttributeRequest retrieveAttributeRequest = new  RetrieveAttributeRequest {
EntityLogicalName = entityName,
LogicalName = attributeName,
RetrieveAsIfPublished = true
// Execute the request.
RetrieveAttributeResponse retrieveAttributeResponse =(RetrieveAttributeResponse)service.Execute(retrieveAttributeRequest);
// Access the retrieved attribute.
Microsoft.Xrm.Sdk.Metadata.PicklistAttributeMetadata retrievedPicklistAttributeMetadata =(Microsoft.Xrm.Sdk.Metadata.PicklistAttributeMetadata)   retrieveAttributeResponse.AttributeMetadata;
// Get the current options list for the retrieved attribute.
OptionMetadata[] optionList = retrievedPicklistAttributeMetadata.OptionSet.Options.ToArray();
string selectedOptionLabel = string.Empty;
foreach (OptionMetadata oMD in optionList)
if (oMD.Value == selectedValue)
selectedOptionLabel = oMD.Label.UserLocalizedLabel.Label;
return selectedOptionLabel;
Posted in CRM SDK, Helpers, Plugins, Uncategorized | Tagged , | Leave a comment

Error 102 Error registering plugins and/or workflows. Assembly bin\Debug\MyPlugin.dll could not be found.

This error

Error 102 Error registering plugins and/or workflows. Assembly bin\Debug\MyPlugin.dll could not be found.

could possibly be caused for many reasons. For me it has been always one of the following:

1. As I use the CRM Developer Toolkit, and sometimes I add an existing project to the plugin solution, I forget to add the Plugin project as a reference to the CrmPackage project.

2. I also sometimes find that I have used different project framework version from the one used by the package.

Posted in Error, Plugins, Uncategorized | Tagged , , , | Leave a comment



When a plugin is triggered, a TypeLoadException error occurrs and it mentions that the plugin cannot load anything from other assemblies in GAC.

OR if you click to open more details about the error you find:

<Message>Could not load type ‘<classname>‘ from assembly ‘<namespace>, Version=, Culture=neutral, PublicKeyToken=50c75133acc12e13′.</Message>


<Message>Unexpected exception from plug-in (Execute): Plugin.Task.PostTaskUpdate: System.MethodAccessException: Attempt by security transparent method ‘Plugin.Task.PostTaskUpdate.ExecuteMethod(LocalPluginContext)’ to access security critical method ‘Plugin.Common.MyClass..ctor()’ failed.


Assembly ‘Plugin.MyClass, Version=, Culture=neutral, PublicKeyToken=00b34ecdd47d454b’ is partially trusted, which causes the CLR to make it entirely security transparent regardless of any transparency annotations in the assembly itself.  In order to access security critical code, this assembly must be fully trusted.</Message>

My Resolution

Make sure plugin is not registered in sandbox mode.

Posted in Error, Plugins, Uncategorized | Tagged | Leave a comment

Microsoft Dynamics CRM Diary Introduction

It happens many times that I struggle with an error while building or running a code in my CRM development career. And it happens as well that I could face the same kind of problems later on with no memory of what I did last time to resolve it.

The method I started to follow recently (thick mind, should have done this ages ago) is using my own storing text diary file into which I log those issues that took me a time to resolve, so I can refer back to them when I fall into the same problem again.

It should be even easier to search into my diary when it is stored online (thick mind again, this is called blogging).

I hope my blog will be useful to other developers struggling out there as well as it should be useful to myself.

Posted in Uncategorized | Leave a comment