An item with the same key has already been added.

Aug 19, 2010 at 7:38 PM

Hello, we have a customer portal installed on our crm and sometimes the crm fall down with this message: An item with the same key has already been added.

It happends when I sign in (via ifd) or open crm locally. After I recycle app pool on IIS everything is ok.

This is the stacktrace:

Error: An item with the same key has already been added.

Error Message: An item with the same key has already been added.

Source File: Not available

Line Number: Not available

Request URL: http://localhost/crm/default.aspx

Stack Trace Info: [ArgumentException: An item with the same key has already been added.]
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at Microsoft.Crm.Metadata.PreloadedAttributeMetadataDataProvider.Initialize(IPreloadedMetadataInitializationConsumerContext context)
   at Microsoft.Crm.Metadata.PreloadedMetadataCacheDataProvider.InitializeAttributes(IPreloadedMetadataInitializationConsumerContext context)
   at Microsoft.Crm.Metadata.PreloadedMetadataCacheDataProvider.Initialize(Guid organizationId, MetadataContainer container)
   at Microsoft.Crm.Metadata.MultiOrgSharableMetadataCacheLoader.CreateMetadataCacheDataProvider(MetadataContainer container, Guid organizationId)
   at Microsoft.Crm.Metadata.DynamicMetadataCacheLoader.BuildMetadataCacheFromMetadataContainer(MetadataContainer container, LoadMasks masks, Guid organizationId)
   at Microsoft.Crm.Metadata.DynamicMetadataCacheLoader.BuildMetadataCacheFromDataSet(DataSet data, LoadMasks masks, Guid organizationId)
   at Microsoft.Crm.Metadata.DynamicMetadataCacheLoader.LoadCacheFromDatabaseInternal(LoadMasks masks, CrmDbConnection connection, CrmTransaction transaction, Guid organizationId)
   at Microsoft.Crm.Metadata.DynamicMetadataCacheLoader.LoadCacheFromDatabase(LoadMasks masks, IOrganizationContext context)
   at Microsoft.Crm.Metadata.DynamicMetadataCacheFactory.LoadMetadataCache(LoadMethod method, CacheType type, IOrganizationContext context)
   at Microsoft.Crm.Metadata.MetadataCache.LoadCache(IOrganizationContext context)
   at Microsoft.Crm.Metadata.MetadataCache.GetInstance(IOrganizationContext context)
   at Microsoft.Crm.BusinessEntities.BusinessEntityMoniker..ctor(Guid id, String entityName, Guid organizationId)
   at Microsoft.Crm.Caching.UserDataCacheLoader.LoadCacheData(Guid key, ExecutionContext context)
   at Microsoft.Crm.Caching.ObjectModelCacheLoader`2.LoadCacheData(TKey key, IOrganizationContext context)
   at Microsoft.Crm.Caching.BasicCrmCache`2.CreateEntry(TKey key, IOrganizationContext context)
   at Microsoft.Crm.Caching.BasicCrmCache`2.LookupEntry(TKey key, IOrganizationContext context)
   at Microsoft.Crm.BusinessEntities.SecurityLibrary.GetUserInfoInternal(WindowsIdentity identity, IOrganizationContext context, UserAuth& userInfo)
   at Microsoft.Crm.BusinessEntities.SecurityLibrary.GetCallerAndBusinessGuidsFromThread(WindowsIdentity identity, Guid organizationId)
   at Microsoft.Crm.Authentication.CrmWindowsIdentity..ctor(WindowsIdentity innerIdentity, Boolean publishCrmUser, Guid organizationId)
   at Microsoft.Crm.Authentication.WindowAuthenticationProviderBase.Authenticate(HttpApplication application)
   at Microsoft.Crm.Authentication.AuthenticationStep.Authenticate(HttpApplication application)
   at Microsoft.Crm.Authentication.AuthenticationPipeline.Authenticate(HttpApplication application)
   at Microsoft.Crm.Authentication.AuthenticationEngine.Execute(Object sender, EventArgs e)
   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Thanks Pavel

Aug 19, 2010 at 8:04 PM
The url you gave is for your CRM, and your CRM server is throwing the error. This doesn't appear to be an error in the customer portal. You might want to post your CRM issue on the CRM forums. Now that said, I want to make sure you installed the portal correctly. In installing the portal, that you did NOT modify your CRM website on your CRM server. For example, the portal is to be installed in a separate website and no IIS modifications are required in your CRM website. If you made modifications to your IIS website for your CRM, that might explain some errors, and the fix would be to undo those changes, get your CRM working again, then follow the customer portal installation docs to install the portal correctly. Thanks, Shan
Aug 19, 2010 at 8:13 PM

The url is from trace log of crm. The problem is maybe in the crm, not in the customer portal, but we have many instances on the server, and the problematic is the customer portal instance only. The portal is running on I am sorry, but its only in czech language. The portal is running on separate server. We tried it on the same server as crm on another site but the situation is the same. I still dont know how to simulate this error. It only sometimes occures and sometimes not :-(


Aug 19, 2010 at 8:20 PM
One more question - the url includes /default.aspx. That is not a standard CRM url (crm uses http://crm-server/org-name/main.aspx), nor is it a url that the portal framework will use. One thing to check - what is your connection string for CRM in your portal site's web.config file? Shan
Aug 19, 2010 at 8:42 PM

I dont know why there is default.aspx in the url, but I think its the page you go through when you are logging into the crm and after you successfully log in, you are redirected to page loader.aspx. This is the crm error when I access CRM with customer portal customization, this is not the problem when I access portal web site. The web.config on the portal website is ok, its running most of the time but sometimes when CRM fall down with this error, the portal web site is not accessible too.