|
It should - my connection to CP was doing all sorts of funny things this morning. Your questions I'm fine with. It's the help vampire above that I am not interested in helping any more.
This space for rent
|
|
|
|
|
I posted this tip that tries to see if an exception in the chain is of a particular type. You could use the code as a basis for bending it to your will.
Find your inner exception
(I don't know what's going on with link pasting.)
".45 ACP - because shooting twice is just silly" - JSOP, 2010
- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Very nice. Thanks!
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I am trying to keep thread/process active, when application is minimized to tray. As i want some tasks to be performed in background in app state = minimize.
As I have defined a async delegate to capture a callback for an event, when the app is minimized the process is completed and the app is supposed to listen for event fire, but when the app is minimized the app does not reports to the event, and the callback to the delegate doesn't occurs but the following event fire and all the respective tasks are performed when app is maximized.
Please guide and help me.
|
|
|
|
|
hassaan mustafa wrote: I am trying to keep thread/process active, when application is minimized to tray Applications do not "minimize to tray". Your process is running and may show a TrayIcon. What you do on "minimize" is completely up to you.
The thread/proces remains active until you exit. So, the obvious idea is not to quit the application when you are "minimizing".
Show us some code and you may get a more specific and/or better answer.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi!
I have published a Microsoft Dynamics NAV page as an OData web service V4.
I used Odata v4 Client Code Genrator ver 2.4.0 to create the Client side proxy classes for my C# project.
When I make a simple call to "myhost/.../Company" everything works like a charm using simple code like this:
NAVCient = new NAVEntities.NAV(new Uri("myhost/.../ODataV4"));
NAVCient.Credentials = new Net.NetworkCredential("usr", "psw");
List<NAVEntities.Company> company = NAVCient.Company.ToList;
I get my list of available Companies. Now I want to get the CustomerCards for my selected Company. I do like this:
NAVCient = new NAVEntities.NAV(new Uri("myhost/.../ODataV4/Company('MyTest')"));
NAVCient.Credentials = new Net.NetworkCredential("usr", "psw");
List<NAVEntities.Customer_Card> Customers = NAVCient.Customer_Card.ToList;
The uri genrated is correct and I can see the response comming back correct using fiddler with all my data. Code gets an exception trying to parse the information. At first i thought the backend had some issues but clearly its the client producing this error bec in fiddler I can see my result and nothing else as a response from server :
"An unhandled exception of type 'Microsoft.OData.Core.ODataException' occurred in Microsoft.OData.Core.dll
Additional information: When writing a JSON response, a user model must be specified and the entity set and entity type must be passed to the ODataMessageWriter.CreateODataEntryWriter method or the ODataFeedAndEntrySerializationInfo must be set on the ODataEntry or ODataFeed that is being written."
Any suggestions/advice?
I have tried other sources and they work as it seem.
Thanks for your help
// henrik
Tags:
|
|
|
|
|
You haven't said specifically which statement is failing.
I would try:
var Customers = NAVCient.Customer_Card;
... = Customers.ToList();
etc.
instead of:
List<NAVEntities.Customer_Card> Customers = NAVCient.Customer_Card.ToList;
And see how far I get from there.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
It is failing on the .ToList part ...
Its very wierd. Tried that thing but same. And wierdest of all why is it trying to write a JSON-response? Sounds more like something from server?
|
|
|
|
|
That was the point.
Inspect the "var" using the debugger before performing the "ToList" and see what you're getting versus what you're expecting.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Will take a look into it ...
Getting back to you!
|
|
|
|
|
The object returned is :
Microsoft.OData.Client.DataServiceQuery(Of Customer_Card)
The object created by the Client generator. I need to call .Execute or something else with collection to
make it execute the query.
If I do that I get :
Microsoft.OData.Client.QueryOperationResponse(Of Customer_Card)
The execution seem ok. Problem is when I start enumerating through the list that shold have been produced. I can clearly see in fiddler that result comming back to me is ok. Something is happening on clientside. Maybe the call itself to the service is doing something wierd. But why should it do that when it works on the query for Company.
Can this has to do with child/relations spec maybe?
Thanks ZD
|
|
|
|
|
You say execution "seems ok" .... Hardly a show of confidence.
Instead of assuming it is "ok", there are a number of properties in the response you should look at (e.g. "Error") to confirm that everything is as it should be.
QueryOperationResponse Class (System.Data.Services.Client)
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Trying executing .Execute on the object of type :
Global.Microsoft.OData.Client.DataServiceQuery(Of Customer_Card)
Gives me this object and I can see in fiddler that response is received and correct but accoring to error TotalCount is missing:
https://postimg.org/image/eyv1hglnj/
However I got the objext I am supposed to.
If I try to call .ToList it first makes call to .Execute and then try to create :
System.Collections.Generic.List(Of NAVEntities.Customer_Card)
But it produces an error and I the object looking like this:
https://postimg.org/image/e3ewt9b5j/
Full stacktrace is:
Microsoft.OData.Core.ODataException was unhandled
HResult=-2146233079
Message=When writing a JSON response, a user model must be specified and the entity set and entity type must be passed to the ODataMessageWriter.CreateODataEntryWriter method or the
ODataFeedAndEntrySerializationInfo must be set on the ODataEntry or ODataFeed that is being written.
Source=Microsoft.OData.Core
StackTrace:
at Microsoft.OData.Core.ODataFeedAndEntryTypeContext.ValidateAndReturn[T](T value)
at Microsoft.OData.Core.ODataFeedAndEntryTypeContext.get_NavigationSourceName()
at Microsoft.OData.Core.Evaluation.ODataConventionalEntityMetadataBuilder.ComputeId()
at Microsoft.OData.Core.Evaluation.ODataConventionalEntityMetadataBuilder.ComputeAndCacheId()
at Microsoft.OData.Core.Evaluation.ODataConventionalEntityMetadataBuilder.GetId()
at Microsoft.OData.Client.Materialization.MaterializerEntry.UpdateEntityDescriptor()
at Microsoft.OData.Client.Materialization.FeedAndEntryMaterializerAdapter.ReadEntryCore()
at Microsoft.OData.Client.Materialization.FeedAndEntryMaterializerAdapter.TryReadEntry(MaterializerEntry& entry)
at Microsoft.OData.Client.Materialization.FeedAndEntryMaterializerAdapter.<LazyReadEntries>d__0.MoveNext()
at Microsoft.OData.Client.Materialization.FeedAndEntryMaterializerAdapter.Read()
at Microsoft.OData.Client.Materialization.ODataReaderEntityMaterializer.ReadNextFeedOrEntry()
at Microsoft.OData.Client.Materialization.ODataEntityMaterializer.ReadImplementation()
at Microsoft.OData.Client.MaterializeAtom.MoveNextInternal()
at Microsoft.OData.Client.MaterializeAtom.MoveNext()
at System.Linq.Enumerable.<CastIterator>d__94`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Data.WebServices.ODataTestApp.MainModule.Main() in Data.WebServices.OData.TestApp\MainModule.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:
Update : I Have error on TotalCount on the Company-call that worked so thats not the case.
modified 5-Jan-17 1:26am.
|
|
|
|
|
Unfortunately, you're posting "code fragments"; which makes it hard to discern what you are or are not doing.
You previously hinted it might be a "relation" thing; yes, data services does "lazy loading"; cannot tell from your post if you addressed this.
How to: Load Related Entities (WCF Data Services)
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Lets see if I can put up a sample thing for you.
Yes lazyloading might be a thing just like in EF. Need to turn it off maybe?
Thanks // zd
|
|
|
|
|
Cant see anything in fiddler that draws me into that relation-direction. Its just plain-data. Have to dive deeper into that.
|
|
|
|
|
I'm thinking the possibility that from Main () can access its copy of Name_Common to do Name_Common.Cls_Common.StCommon = new Name_Common.St_Common(); For now I do not know how to do it because there is an error. So when I want to use a class, I can copy Main's global structure to that of the class. I have remembered that I did a function to make (cast) of one estrcuture to another one.
For now I can not make new Name_Common.St_Common(); of Main(). The brain has stopped me for days. I can also someone something about points 2 and 3 of debugger employment? Thank you.
|
|
|
|
|
What has this got to do with this question? Please don't hijack others posts.
This space for rent
|
|
|
|
|
|
I am on to it ...
Getting back ...
//zd
|
|
|
|
|
Everything ok with browsing the service. Filtering etc work like a charm. This is for sure client-issue.
I have tried to generate proxyclasses using 2 different tools that state they can produce proxy for OData v4.
If I try to use Add Service Reference I get en error like this :
Quote: The document at the url file:///e:/client.xml was not recognized as a known document type.
The error message from each known type may help you fix the problem:
- Report from 'XML Schema' is 'The root element of a W3C XML Schema should be <schema> and its namespace should be 'http://www.w3.org/2001/XMLSchema'.'.
- Report from 'DISCO Document' is 'Discovery document at the URL file:///e:/client.xml could not be found.'.
- The document format is not recognized.
- Report from 'WSDL Document' is 'There is an error in XML document (2, 2).'.
- <edmx xmlns="http://docs.oasis-open.org/odata/ns/edmx"> was not expected.
If the service is defined in the current solution, try building the solution and adding the service reference again.
Guess That built in proxyclass generator only handles up to V3?
This is what my Schema look like:
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
<edmx:DataServices>
<Schema Namespace="NAV" xmlns="http://docs.oasis-open.org/odata/ns/edm">
Thanks
|
|
|
|
|
Yes; when your previously mentioned you used a "generator" .... It's almost a given you will have less control and less transparency.
I usually go "down to the metal" first time around; and then I MAY go "fancy".
OData - the Best Way to REST
Home · object/Simple.OData.Client Wiki · GitHub
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Thanks Gerry ...
yes I dont like it either but client wanted an easy way to code against Microsoft Dynamics.
I have been all over that Odata-site and everything work as intended if you do it the raw way,
I do like the look of Simple.OData.Client. Maybe try it out. Have you tested it?
We are sending in the question to NAV developement team to see if they have any answer to why it dont work with a generator.
Thanks for all your help 
|
|
|
|
|
You're welcome.
No, I haven't tried "Simple.OData.Client"; but it has a good "smell".
But if your "raw" methods are working, I wouldn't bother.
I also wouldn't bother NAV. I would instead consider spending time giving the client an "attitude adjustment".
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
We are on the same level
I try out the Simple Client. I love the smell too.
//ZD
|
|
|
|