Thursday, May 22, 2008

My CRM problems when importing entities

As I mentioned in the previous post I had problems with the CRM after importing entities. Now I have found the problem, the entity in question had Relation to custom entity in the other CRM that I did not include in the export package. This caused the problem that the attribute from the relation was not found and all the troubles.

So when you export the entities from MS CRM always export all related entities, but at the import phase import only those what you need.

Labels: , ,

MS CRM 4.0 prepare for diagnostics and debugging

I am working on project where we are making quite a few integrations to the CRM. And yesterday I got into a trouble.

A colleague of mine has created on his development machine few new entities. I exported the customizations and then imported them in my CRM development, and here is started. One of the entities was not showing the Icon, I couldn't open the new form, I couldn't do anything with that entity. I have tried to delete the customization and again nobody. Like a friend said "A BIIIG PROBLEM".

Here is how I have solved it.

  1. Turned on the development error in the web.config.

    <appSettings>

    <add key="DevErrors" value="On"/>

  2. Turned on the tracing http://support.microsoft.com/kb/907490
  3. Then it seems that I had to recreate two attributes that were added and then deleted, but somehow the CRM new about them even when the entities were exported.

So good luck to you too when you are looking for errors with the CRM.

Labels: , , ,

WCF web serivce host and polymorphism

Well I have been working on the project with WCF web service with some polymorphism to make it extensible.
So here it is the situation:
Projects
- Library project - contains few interfaces and the base classes for the entities that are exposed so let's say that there we have
[IDataContract]
public abstract class Entity
- WCF web service project - contains interface for the web service and the actual web service
[IServiceContract]
public interface IMyService
{
public Entity GetEntity(Guid ID);
}

The service itself loads from the database what type of Entity to instantiate and does that using Reflection
- Email project - this is the first project that references the Library project and inherits from the Entity class.
public EmailEntity:Entity

so everything worked just fine when using the development server, but the troubles began when I decided to host the web service in IIS 6.

I have made the svc file, the correct web.config, and I got WSDL, created client application, and when I have tried to call GetEntity ops I got exception, kind a strange one.
I have used the Object Browser in VS to check what is wrong, and here it was - there was no EmailEntity type. Well this was normal, the web service did not know anything about that type at the compilation. I have started to dig and here is what I have found.
If you use KnownType attribute in the code then you can inform the web service that the EmailEntity is avaliable, but in the code....
So looked a bit more and found

<system.runtime.serialization>

<dataContractSerializer>

<declaredTypes>

<add ......

    <knownType

type="Email.EmailEntity,Email,Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />

</add>

</declaredTypes>

</dataContractSerializer>

</system.runtime.serialization>

This was the way to expose the type just in the configuration.

Labels: , , ,