=======================================================
String cannot be of zero length.
Parameter name: name
at System.Security.Principal.NTAccount..ctor(String name)
at Microsoft.Dynamics.Security.Helper.GetSidString(String ntAccountName)
at Microsoft.Dynamics.Security.SecurityContext..ctor()
at Microsoft.Dynamics.Common.SecurityServiceManager.GetSecurityContext(Context context)
at Microsoft.Dynamics.Common.SecurityServiceManager.GetRoles(Context context)
at Microsoft.Dynamics.Common.Context.Validate(ValidationResult validationResult, Context context)
at Microsoft.Dynamics.Common.BusinessService.GetList[DetailType,SummaryType](Criteria criteria, Context context)
========================================================
Following code(from sample) generating above error, where it went wrong? thanks a lot.
=========================================================
string MyCompanyName;
MyCompanyName = myComObj.GetConfigKey("Company").Trim();
Context context;
LikeRestrictionOfString companyRestriction;
CompanyCriteria companyCriteria;
Company[] MyCompany;
// Create a context object
context = new Context();
// Set up the context object
// To retrieve from the system database set the organization key to null
context.OrganizationKey = null;
context.CultureName = "en-US";
// Create a restriction object to query by company ID
// Query for all possible company ID values
companyRestriction = new LikeRestrictionOfString();
companyRestriction.Like = MyCompanyName ;
// Create a company criteria object and add the restriction object
companyCriteria = new CompanyCriteria();
companyCriteria.Name = companyRestriction;
// Retrieve the list of companies
MyCompany = MyDynamicsGP.GetCompanyList(companyCriteria, context);
return MyCompany[0].Key.Id ;
*This post is locked for comments