Friday, January 27, 2012

CRM 2011 - Outlook offline Error : Unable to load plug-in assembly


When you start a plug-in assembly in the Microsoft Dynamics CRM 2011 client for Microsoft Office Outlook, you receive the following error message:

Unable to load plug-in assembly

This error occurs when you register the plug-in assembly for offline use. You must add the plug-in public key token in the allowlist, in order to solve this issue.

1. Copy Public key token value under Microsoft Dynamics CRM solution information


MSCRM public token key
     
                                                                                                                                   
2. Create sub key folder with Public Key Token value: HKEY_CURRENT_USER\Software\Microsoft\MSCRMClient\AllowList\384531507f3

3. Check if public key is created and try your plugin.

It's very simple to generate a script file for key creation, you can see two helpful examples in attachments section.


Thanks,
Nicola Grillo



Reference

Friday, January 20, 2012

SQL SERVER - Restore Database via T-SQL

Ck logical name with the following query:


Query


RESTORE FILEONLY FROM DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\<My DB>_MSCRM.bak'


Result:
Run the following query:



Query


RESTORE DATABASE [<My DB>_MSCRM]
FROM DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\<My DB>_MSCRM.bak'
WITH FILE = 1, MOVE N'mscrm' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\<My DB>_MSCRM.mdf',
MOVE N'mscrm_log' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\<My DB>_MSCRM_log.LDF',
NOUNLOAD, REPLACE, STATS = 10
RESTORE DATABASE [<MY DB>_MSCRM]


Nicola Grillo

CRM 2011 - ActivityParty System.Runtime.Serialization.SerializationException

When you start a plug-in assembly in the Microsoft Dynamics CRM 2011 client for Microsoft Office Outlook and you receive the following exception message:

Exception

The Web Service plug-in failed in OrganizationId: b4a5466e-8038-080027d06cae; SdkMessageProcessingStepId: 5263132e-3584-410d-ad1f-70702a62; EntityName: appointment; Stage: 15; MessageName: Create; AssemblyName: Microsoft.Crm.OfflineQueuePrimaryKeyPlugin, Microsoft.Crm.ObjectModel, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31b56ad364e35; ClassName: Microsoft.Crm.OfflineQueuePrimaryKeyPlugin; Exception: Unhandled Exception: System.Runtime.Serialization.SerializationException: Type 'Xrm.ActivityParty[]' with data contract name 'ArrayOfActivityParty:http://schemas.datacontract.org/2004/07/Xrm' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeAndVerifyType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, Boolean verifyKnownType, RuntimeTypeHandle declaredTypeHandle, Type declaredType)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiType(XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle objectTypeHandle, Type objectType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle, Type declaredType)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
   at WriteKeyValuePairOfstringanyTypeToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , ClassDataContract )
   at System.Runtime.Serialization.ClassDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithoutXsiType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
   at WriteAttributeCollectionToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , CollectionDataContract )
   at System.Runtime.Serialization.CollectionDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithoutXsiType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
   at WriteEntityToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , ClassDataContract )
   at System.Runtime.Serialization.ClassDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeAndVerifyType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, Boolean verifyKnownType, RuntimeTypeHandle declaredTypeHandle, Type declaredType)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiType(XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle objectTypeHandle, Type objectType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle, Type declaredType)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
   at WriteKeyValuePairOfstringanyTypeToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , ClassDataContract )
   at System.Runtime.Serialization.ClassDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithoutXsiType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
   at WriteParameterCollectionToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , CollectionDataContract )
   at System.Runtime.Serialization.CollectionDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithoutXsiType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
   at WriteOrganizationRequestToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , ClassDataContract )
   at System.Runtime.Serialization.ClassDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithoutXsiType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.DataContractSerializer.InternalWriteObjectContent(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
   at System.Runtime.Serialization.DataContractSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
   at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
   at System.Runtime.Serialization.DataContractSerializer.WriteObject(XmlWriter writer, Object graph)
   at Microsoft.Crm.BusinessEntities.SoapContext.SerializeSdkRequest(OrganizationRequest requestToSerialize, Entity target, ExecutionContext context)
   at Microsoft.Crm.BusinessEntities.SoapContext.SerializeRequestWithEntity(DynamicEntity dynamicEntity, IOrganizationContext context)
   at Microsoft.Crm.BusinessEntities.SoapContext.GenerateModifiedSoapPacket(DynamicEntity entity, String requestName, String targetName, IOrganizationContext context)
   at Microsoft.Crm.OfflineQueuePrimaryKeyPlugin.Execute(IServiceProvider serviceProvider)
   at Microsoft.Crm.Extensibility.V5PluginProxyStep.ExecuteInternal(PipelineExecutionContext context)
   at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)



This exception occurs when you use XRM.ActivityParty in your Offline Plugin. In this case you have to change your Plug-in code in order to solve this issue.


Example :


If you use the following code:


Example

ActivityParty activitypartyentity=new ActivityParty();
....

Or

ActivityParty[] arrayofactivityparty=....
You have to change your code as the following:

Example

Entity activitypartyentity=new Entity("activityparty");
....
..
or


Entity[] arrayofactivityparty=....



Nicola Grillo

Wednesday, January 11, 2012

CRM 2011 - Plugin Error System.InvalidCastException: Unable to cast object of type 'xxxx' to type 'Microsoft.Crm.Sdk.IPlugin'.

This error occurs when in your plug-in have an reference code conflict to the Microsoft Dynamics CRM SDK 4.0 . In order to solve this issue you need to remove all  Microsoft Dynamics CRM 4.0 conflicts!


Nicola Grillo

Monday, January 9, 2012

CRM 2011 - Plugin registration tool Error only Isolate plugin


I got this error after latest update with the Roll 4 to the plugin registration tool when i tried to registry a new assembly . I solve it with a remove of the Connections.config.xml in the plug-in registration tool folder.


Nicola Grillo