Once In A White Moon - by Gina Therese Hvidsten
© 2017
Once In A White Moon

WPF, EntityFrameworkCore and SQLite

After starting on a new programming project I needed some way to have the application persist data between sessions. I eventually found SQLite, and the enthusiasm grew as I found out that there is an EntityFramework provider for this. Microsoft has even went a step further and made an EntityFrameworkCore implementation, which even supports migrations (albeit limited). When I saw that EntityFrameworkCore was supported even in regular .NET applications I reached peak enthusiasm and decided that this was my path. I eagerly started reading Microsoft’s “Getting started” documents, and almost immediately ran into problems. The migrations described in the previous link all mention running “dotnet ef” commands. The problem is that the documentation doesn’t specify where to execute those commands. And when I finally found out that […] Read more

I managed to finish a new project!

As some of you know I’m very good at starting new projects… not so good at finishing them. This time, however, I’ve actually done it! I came up with a new project, started doing it, and have now actually finished it! At the office we have some hardware with a serial port and we needed to see what kind data was sent from the hardware. Initially I thought that that would be easy as there should be many simple tools for this on the internet. I was wrong. We downloaded a lot of different tools, but none worked. After a while we finally found one that worked, but that only had a trial version (which sufficed for our quick debugging). Seeing as this kind of software […] Read more

Webservice calls hangs and gets a timeout exception

Recently I encountered a problem using webservices in .Net. At irregular intervals the code suddenly threw the following exception when calling a webservice: System.Net.WebException: The operation has timed out There was nothing magical in the code around the calls to the webservice where it was handled in the usual fashion:

When the code reached ws.Foo() it just waited there for over a minute before throwing the previously mentioned exception. Since using webservices is extremely streamlined and standardized in Visual Studio I initially thought the problem had to lie somewhere else than my application, like maybe there were networking issues or the ISS server that hosted the webservice had some problems. When troubleshooting all of the above and nothing panned out I was back to […] Read more

Printing XPS files to a physical printer

I had the need to programatically print an XPS file, but a couple of hours of Google searches only returned examples of how to print TO an XPS file. It was extremely difficult to find how to send a XPS file to an actual physical printer. Eventually something turned up and the solution seemed to be the XpsDocument class. Look at this simplified example to see how easy it turned out to be:

As you can see, reading a XPS file and then sending the contents to a printer is not very hard at all.