I'm running the following code to access CRM Dynamics DB.
using (OrganizationServiceProxy proxy
= new OrganizationServiceProxy(organizationUri, null, credentials, null))
{
const String request = @"
<fetch mapping ='logical'>
<entity name = 'account'>
<attribute name = 'name'/>
</entity>
</fetch>";
FetchExpression expression = new FetchExpression(request);
EntityCollection result = proxy.RetrieveMultiple(expression);
...
}
I'm fairly sure that organizationUrl
and credentials
are correct. According to this walk-through, the other two can be set to null
for this simple case.
The problem is that when I get to the last line, retrieval to result
, I get Exception
telling me that:
System.ArgumentNullException was unhandled
Message=Value cannot be null.
Parameter name: CurrentServiceEndpoint
What did I forgot and how do I resolve this problem?
EDIT:
System.ArgumentNullException was unhandled
HResult=-2147467261
Message=Value cannot be null.
Parameter name: CurrentServiceEndpoint
Source=Microsoft.Xrm.Sdk
ParamName=CurrentServiceEndpoint
StackTrace:
at Microsoft.Xrm.Sdk.ClientExceptionHelper.ThrowIfNull(Object parameter, String name)
at Microsoft.Xrm.Sdk.Client.ServiceConfiguration`1.CreateChannelFactory(ClientCredentials clientCredentials)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceConfiguration.CreateChannelFactory(ClientCredentials clientCredentials)
at Microsoft.Xrm.Sdk.Client.ServiceProxy`1.get_ChannelFactory()
at Microsoft.Xrm.Sdk.Client.ServiceProxy`1.CreateNewServiceChannel()
at Microsoft.Xrm.Sdk.Client.ServiceProxy`1.ValidateAuthentication()
at Microsoft.Xrm.Sdk.Client.ServiceProxy`1.get_ServiceChannel()
at Microsoft.Xrm.Sdk.Client.ServiceContextInitializer
1.Initialize(ServiceProxy
1 proxy)at Microsoft.Xrm.Sdk.Client.ServiceContextInitializer
1..ctor(ServiceProxy
1 proxy)at Microsoft.Xrm.Sdk.Client.OrganizationServiceContextInitializer..ctor(OrganizationServiceProxy proxy)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.RetrieveMultipleCore(QueryBase query)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.RetrieveMultiple(QueryBase query)
at CRM_Server_Accessor.Program.Main(String[] args) in C:\Users\Viltersten\documents\Software\Projects\CRM_Server_Accessor\Program.cs:line 60
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
organisationUri
toOrganizationServiceProxy
constructor, but your post refers toorganisationUrl
(which makes me sound a bit pedantic ;) ) – Greg OwensSecurityAccessDeniedException
if the creds were wrong... That's what I got when I tried the hosted version, namely. But the online barks about argument null for end point... – Konrad Viltersten