Monday, December 2, 2013

From concept to reality in 6 weeks - part 11

I am skipping part 10 since yesterday was like a whole day's work when I intended to only work a half day. Since I have worked two half days that has to count for a whole day. Since I was working with someone else yesterday I did not keep up the blog while working with him, so a little catch up first.

I committed the cardinal sin of Windows development in that I had no rebooted my computer a single time since installing the initial patches to get the machine working. What was I thinking? Did I think that things were magically fixed by moving to Windows 8? It finally bit me as I could not build a deployable Windows 8 app as VSE complained that the simulator was running. I doubled checked all of the processes using Task Manager and it was definitely not running. I closed VSE and reopened it and nothing was fixed. I was working with the mapping engine lead developer and I showed him the message. He immediately told me to reboot my Windows laptop. He said he has to reboot his machine multiple times a day as the Visual Studio Professional that he uses gets slower and slower during the day's usage. Then I remembered what I was working on. I used to work at a company that had a policy that every one had to reboot their computer each evening - the justification was so they could install nightly patches on the whole company intranet and did not want anything running that would prevent the installers from succeeding. I am going to have to remember to reboot my Windows 8 machine every weekend whether I want to do it or not.

Rebooting definitely fixed part of my problem, but I had to look up the error code on the MSDN error page to determine what the message meant and it showed 0x80073D05 as the error code. The last error I saw when I gave up was 'Could not copy the file "obj\x86\Release\Bing.Maps\Themes\Generic.xbf"'. That message is odd since I had commented out the Bing Maps to switch temporarily to the mapping engine in my MainPage.xaml file. I am going to forget about that for now as I was trying to make a release build to give to the mapping engine developer to see if it worked for him. He did the amazing thing of getting Windows 8.1 to work from BootCamp on his Mac. He did say if he had to do it all over again he would not do it as it was very painful and not worth it. He also made an executive decision to use the ANGLE open source project which maps OpenGL on top of DirectX on Windows, which greatly sped up his development time.

When I clean my VSE project, I have to remember that I must manually copy the mapping engine DLL files from "bin\x86\Debug" to "bin\x86\Debug\AppX" folder temporarily until they fix the reference dependencies to work correctly in VSE. Now I am getting another seemingly unrelated error so I am reboot to start from a fresh slate this morning since we were doing all kinds of interesting things last night to get the mapping engine working and for me to make a release build.

After rebooting I was able to run the app once and the second time I ran it I got a dreaded error message:
An unhandled exception of type 'System.AccessViolationException' occurred in ...
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
What that means is that it is time to send this to the mapping engine developer and switch back to Bing Maps so I can finish the JSON parsing today.

As of this morning, I have someone else helping me build a custom component for a dual range slider! That is great news since he is also a Windows developer and can help me when I get stuck on other tasks. Now I am feeling better already. We connected using Skype from my Mac but I could not get the microphone to work on Skype on my Windows laptop. That is when I gave up and switched to GoToMeeting as I knew he could help me get that to work where I failed last week. We also worked thru issues of me showing my screen from the Windows laptop. I was trying to use the GoToMeeting from the Windows Store, but when I switched to using the http://gotomeeting.com site then I was able to login and then change presenter from my Mac to my Windows machine. The only problem I encountered was the display was truncated at the bottom so I had to go into the PC Settings for the Display and reduce the resolution. It was good enough for a short demo.

Now I have the fun of trying to find my NullReferenceException that is causing the app to crash when I download the server data. I search for help in Mrs. Google and found an article that has the great keyboard accelerator that is really hard to type : Esc + Ctrl + Alt + E. I added a checkbox for "Common Language Runtime Exceptions". Enabling that immediately found the problem - I remember having to do that a long time ago in a Java land far far away. I also had to do it with Adobe Flex development. That just seems like a very long time ago and I am not happy to have to go back there again.

Once I fixed the problem with my initialization of the active downloads array by moving it into the constructor, I moved onto the parsing the JSON which I had written but could not verify yet because of the exception. I had a couple of conversion issues that I had to deal with as I thought the JSON had numbers but they were strings and vice versa. Nothing a couple of IF statements won't fix like the following by looking at the JsonObject Class documentation:
JsonValue value = jsonObject.GetNamedValue("id");
Id = (jsonValue.ValueType == JsonValueType.Number) ? value.GetNumber() : value.GetString();
The next JSON issue I had to deal with was one of the values can have a value of "null". It is a shame I have to deal with all of these edges cases, but if I don't then I have to deal with exceptions. Let me see, that is a hard decision. OK - I decided I need to check for NULLs like this:

jsonObject["id"] = (Id == null) ? JsonValue.CreateStringValue("") : jsonValue.CreateStringValue(Id);
Now I have 2 of the 3 APIs working by calling the server asynchronously, process the response as JSON, store into DAO objects and then call ToString() to verify they look OK. Now I am making serious progress, except I left the most difficult one for the end. I was building up my confidence to make sure I understood how to process JSON before tackling the tough one.

I must say that listening to Mark Knopfler and Chet Atkins playing together on "Neck and Neck" definitely makes working on Windows more pleasant. I used to listen to Chet Aktins when I was a kid and he got me hooked on playing guitar.

The last JSON is definitely non-standard but at least now that I am an C# JSON parsing expert, I can definitely finish the parsing later today when I get home. A couple of interesting things I learned today, how to parse a DateTimeOffset and the standard date time formats available in C#.

I need to take a break and do some physical exercise like running.

No comments: