The given key was not present in the Dictionary.
-
Saturday, April 28, 2012 10:09 AM
Hi All,
I have a problem like this, I have two servers
1. Development Server
2. Production server
My code in development server is working fine, but the same code in the production server is not working, it is giving an error saying " The given key was not present in the Dictionary". Every thing is same.
Now what i am doing in that code is i am creating an account, on creation of account I am creating a case, this much i am doing but it is not working on production server.
Does any body have any Idea?
I tried a lot but it is not going away? I will be greatfull to all of you please through some light on this.
Thanks and Regards
Ravi
All Replies
-
Saturday, April 28, 2012 10:16 AMAnswerer
Hi Ravi,
Can you download the log file and find at which line of code you are getting the exception - without the exact details we can't help.
Scott
Scott Durow
Read my blog: www.develop1.net/public
If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful" -
Saturday, April 28, 2012 10:23 AMModerator
Hi Ravi,
This error comes when you are trying to access some field value which is not present in propertybag, so it is always better to put a check field availabe in property bag or not before fetching it's value, make sure you have applied try and catch block in your code and try to throw innerexecption and see if you can get some informative text there.
Mahain : Check My Blog
Follow me on Twitter
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question. -
Saturday, April 28, 2012 10:28 AM
Hi Scott,
The line at which it is giving error
Entity entityCase = TaskCreation.CaseCreation(AccountNumber, accountnameid, service, Accountcreation, requestType);
Guid CaseId = (Guid)entityCase.Attributes["incidentid"];
When i am trying to read CaseId it is giving problem, but the same is working on development server.
Thanks and Regards
Ravi
-
Saturday, April 28, 2012 10:31 AMAnswerer
Hi Ravi,
It looks like there is an issue in the TaskCreation.CaseCreation method - since the error you are getting is most likely due to the incidentid not being added to the Attributes collection.
Could you post the code from inside CaseCreation.
Scott
Scott Durow
Read my blog: www.develop1.net/public
If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful" -
Saturday, April 28, 2012 11:11 AM
Hi Scott,
I am creating Case in account plug-in on creation of Plug-in POST Operation
Casecreation code is
publicEntityCaseCreation(stringAccountNumber, GuidAccountNameid, IOrganizationServiceservice, boolAccountCreation, intrequestType)
{
EntityentityCase = newEntity("incident");
if(AccountCreation == true)
{
entityCase[
"title"] = "New Customer Order Execution "+ "A/C No - "+ AccountNumber;
entityCase[
"caseorigincode"] = newOptionSetValue(843650000);
entityCase[
"casetypecode"] = newOptionSetValue(843650000);
entityCase[
"vovinet_servicetype"] = newOptionSetValue(843650000);
}
else
{
entityCase[
"title"] = "Existing Customer Request Execution "+ "A/C No - "+ AccountNumber;
entityCase[
"caseorigincode"] = newOptionSetValue(843650000);
entityCase[
"casetypecode"] = newOptionSetValue(3);
entityCase[
"vovinet_requesttype"] = newOptionSetValue(requestType);
}
// Adding Account Number to the customer field
GuidCustomerId = AccountNameid;
stringCustomerType = "account";
entityCase[
"customerid"] = newEntityReference(CustomerType, CustomerId);
service.Create(entityCase);
returnentityCase;
}
-
Saturday, April 28, 2012 11:19 AM
Hi Scott,
log file reads as follows
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: The given key was not present in the dictionary.Detail:
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
<ErrorCode>-2147220891</ErrorCode>
<ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
<KeyValuePairOfstringanyType>
<d2p1:key>OperationStatus</d2p1:key>
<d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">0</d2p1:value>
</KeyValuePairOfstringanyType>
</ErrorDetails>
<Message>The given key was not present in the dictionary.</Message>
<Timestamp>2012-04-28T11:18:18.6984153Z</Timestamp>
<InnerFault i:nil="true" />
<TraceText>[AccountSvcs: AccountSvcs.AccountServicesCreatePostOperation]
[fd2977a1-0591-e111-8a20-80ee7331b573: AccountSvcs.AccountServicesCreatePostOperation: Create of vovinet_accountservices]</TraceText>
</OrganizationServiceFault>Thanks and Regards
Ravi
-
Saturday, April 28, 2012 12:33 PMAnswerer
Hi,
It could be because you are not assigning the incidentid value to the value returned from service.Create. The id is not automatically assigned.
Hth,
Scott
Scott Durow
Read my blog: www.develop1.net/public
If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful" -
Saturday, April 28, 2012 12:48 PM
Hi Scott,
The same code is working fine in development server, problem is only in Production server.
what do you think can be the reasons.
Thanks and Regards
Ravi
-
Saturday, April 28, 2012 2:52 PM
Hi Ravi,
Please cross check your all field's (used inside plugin) name in production environment. It seems field is missing or may be field name is different in production environment.
- Edited by _Vikram Saturday, April 28, 2012 2:54 PM
-
Saturday, April 28, 2012 3:21 PMAnswerer
Hi,
I'm not convinced that this code is causing the issue- do you know where the trace messages are coming from - it talks about 'AccoutSvcs'?
Could it be that in Production you have different plugins registered?
scott
Scott Durow
Read my blog: www.develop1.net/public
If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful" -
Sunday, April 29, 2012 4:07 PMYour code looks perfect.
1. Verify your OptionSetValues are same on Development environment and production environment.
For example
entityCase["caseorigincode"] = newOptionSetValue(843650000);
Note: by default caseorigincodes are 1, 2, 3. make sure the optionsetvalues are correct
Make sure the optionSet value of case originCode are same in production environment(83650000) and development environment.
2. Verify schema name of your Dev environment and production environment
I have doubt in "vovinet_requesttype"; make sure it exists in production environment. and its schema name is same (vovinet_requesttype);
I hope this helps. If my response answered your question, please mark the response as an answer and also vote as helpful.
Mubasher Sharif
Check out my about.me profile!
http://mubashersharif.blogspot.com
Linked-In Profile
Follow me on Twitter!
- Edited by MubasherSharif Sunday, April 29, 2012 4:09 PM
- Edited by MubasherSharif Sunday, April 29, 2012 4:10 PM
-
Monday, April 30, 2012 5:32 AM
Hi Mubasher,
1. The option set values for the caseorigincode is correct only - I created new optionsetvalue "System" with a value 843650000 apart from phone, E-mail, web which are already present,
I created new optionset as the case is system generated.
So the new optionset consist of following values
Phone - 1
Email - 2
Web - 3
System - 843650000
2. vovinet_requesttype is present in both production and development environment
The thing code is working fine in dev environment but I dont understand why it is not working in Production environment.
That to in production environment code is working fine till last week. I dont know why suddently it is started behaving like this.
I am going crazy with this.
Thanks and Regards
Ravi
-
Monday, April 30, 2012 5:43 AM
Hi Ravi,
You could also try with below code
Guid caseId = ((EntityReference)entityCase.Attributes["incidentid"]).Id;Thanks, Ankit Shah
Inkey Solutions, India.
Microsoft Certified Business Management Solutions Professionals
http://www.inkeysolutions.com/MicrosoftDynamicsCRM.html -
Monday, April 30, 2012 5:46 AM
Hi Scott,
I registerd the plug-in in create Post - Operation in Production and the same in Developement environment. I dont know the issue
I am just going crazy with this.
In fact the code in the production environment working fine till last week , and it suddenly behaving like this.
Thanks and Regards
Ravi
-
Monday, April 30, 2012 5:48 AM
Hi Vikram,
Yes I verified the all the fields are present, in production environment also.
Thanks and Regards
Ravi
-
Monday, April 30, 2012 5:48 AM
Ravi,
Did you change anything on production server in last week?
If you having more plugins on same entity and step then try to verify the execution order of plugin steps.
Thanks, Ankit Shah
Inkey Solutions, India.
Microsoft Certified Business Management Solutions Professionals
http://www.inkeysolutions.com/MicrosoftDynamicsCRM.html -
Monday, April 30, 2012 6:02 AMAnswerer
Hi,
Can you enable platform tracing and find the detailed info on this error.
Scott
Scott Durow
Read my blog: www.develop1.net/public
If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful" -
Monday, April 30, 2012 6:45 AM
Hi Scott,
Can you please tell me how to enable platform tracing.
Thanks and Regards
Ravi
-
Monday, April 30, 2012 6:46 AM
Hi Ankit,
Nothing I have changed , steps and everying i checked again both are same, I checked number of tiems but i am not finding difference
Thanks and Regards
Ravi
-
Monday, April 30, 2012 6:53 AM
to enable trace you could use below tool
Thanks, Ankit Shah
Inkey Solutions, India.
Microsoft Certified Business Management Solutions Professionals
http://www.inkeysolutions.com/MicrosoftDynamicsCRM.html- Proposed As Answer by Ankit Himmatlal Shah Monday, April 30, 2012 6:54 AM
- Unproposed As Answer by E Ravi kumar Monday, April 30, 2012 7:03 AM
-
Monday, April 30, 2012 7:05 AM
Hi Ankit
My main problem is not enabling platform trace, my main problem is " The given key was not present in the dictionary"
so i am removing Mark as answer
Thanks and Regards
Ravi
-
Monday, April 30, 2012 7:49 AM
Hi Scott,
Finally the problem is solved.
The only difference between two servers is Rollup 7 Which is installed on production server on 23-April-2012.
We un-installed the Rollup 7 code is running fine
It is giving problem in following entities
Account
Case
Activitiy
Thanks and Regards
Ravi
- Marked As Answer by E Ravi kumar Monday, April 30, 2012 7:50 AM
-
Monday, April 30, 2012 8:30 AMAnswerer
Well done Ravi,
Thanks for letting us know - it will be interesting to find out if when you install UR7 on your dev servers if the problem appears again. If it does, enabling platform trace is the way we can work out what's going on. I would recommend you get to the bottom of it since you will want to install the latest roll ups on production as soon as possible.
Scott
Scott Durow
Read my blog: www.develop1.net/public
If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful" -
Monday, April 30, 2012 8:39 AM
Hi Scott,
Thanks
Yes thats what i am going to do , first install UR7 on dev server test it and then install it on Production server, definitely i will enable platform tracing and then check what exactly happening.
I will definitely let you know, what exactly happening.
Thanks and Regards
Ravi