web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / Access D365 AX using o...
Finance forum

Access D365 AX using odataclient C#

(0) ShareShare
ReportReport
Posted on by 737

I’m trying to access D365 AX using odataclient C#

1.I have downloaded solution from NuGet (https://github.com/Microsoft/Dynamics-AX-Integration)


2.In ClientConfiguration class I have assigned required variables partly by taken information from Azure portal

3187.jpg
3.To the ODataUtility project, I added an Item ("OData v4 Client Code Generator") as described here (community.dynamics.com/.../integration-with-dynamics-365-for-operations-using-odata-proxy-generator) by modifying public const string MetadataDocumentUri ,

6787.jpg

so the ("OData v4 Client Code Generator") has created a ODataClient.cs

1234.jpg

4.So, finally, when I try to run the Program

3835.jpg

 it cause the error

System.TypeInitializationException was unhandled

  HResult=-2146233036

  Message=The type initializer for 'GeneratedEdmModel' threw an exception.

  Source=ODataUtility

  TypeName=GeneratedEdmModel

  StackTrace:

       at ODataUtility.Microsoft.Dynamics.DataEntities.Resources.GeneratedEdmModel.GetInstance()

       at Microsoft.OData.Client.DataServiceClientFormat.get_ServiceModel()

       at Microsoft.OData.Client.DataServiceClientFormat.UseJson()

       at ODataUtility.Microsoft.Dynamics.DataEntities.Resources..ctor(Uri serviceRoot) in C:\Users\MyUser\Documents\Visual Studio 2015\Projects\Dynamics-AX-Integration-master\ServiceSamples\ODataUtility\ODataClient.cs:line 31

       at ODataConsoleApplication.Program.Main(String[] args) in C:\Users\MyUser\Documents\Visual Studio 2015\Projects\Dynamics-AX-Integration-master\ServiceSamples\ODataConsoleApplication\Program.cs:line 19

       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:

       HResult=-2147024885

       Message=[C:\Users\MyUser\Documents\Visual Studio 2015\Projects\Dynamics-AX-Integration-master\ServiceSamples\ODataConsoleApplication\bin\Debug\ODataUtility.dll] No string associated with token.

       Source=ODataUtility

       StackTrace:

            at ODataUtility.Microsoft.Dynamics.DataEntities.Resources.GeneratedEdmModel.LoadModelFromString()

            at ODataUtility.Microsoft.Dynamics.DataEntities.Resources.GeneratedEdmModel..cctor() in C:\Users\MyUser\Documents\Visual Studio 2015\Projects\Dynamics-AX-Integration-master\ServiceSamples\ODataUtility\ODataClient.cs:line 54685

       InnerException:

I see that error is raised here

7737.jpg

  1. I tried google with “No string associated with token” and found this post (left actually unanswered I think) https://www.codeproject.com/Questions/1259879/Access-D365-AX-using-odataclient-Csharp
  2. Also, when I started creating of this post, I was suggested similar topics (but non of them is what I need)

12076.jpg

https://community.dynamics.com/365/financeandoperations/f/dynamics-365-for-finance-and-operations-forum/308385/access-odata-using-c-http-library/892939#892939

https://community.dynamics.com/ax/f/microsoft-dynamics-ax-forum/251476/write-business-logic-using-c-but-can-i-use-entity-framework

So, the question is: how to fix the error "No string associated with token" ?

My high level Goal is to put a pictures to AX by using DataEntity (https://community.dynamics.com/365/financeandoperations/f/dynamics-365-for-finance-and-operations-forum/364560/import-images-into-ax - thank you Martin, thank you Nikolaos but management/architect  has decided to store pictures in AX) - so maybe I choose wrong direction ?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans