Skip to content

Posts from the ‘C#’ category

  • In the past few years, I have presented multiple sessions all around the world, although mostly virtual. Presenting for a live crowd was something I only did inside The Netherlands before. With restrictions being lifted during 2022, new opportunities presented themselves and I was able to be in front of a live audience again, even outside the country!
  • I recently joined the Advent of Code 2021. During the first 25 days of December, the challenges made me (re)discover many possibilities with C#, some that are long available but maybe not that well known. I share my code and list of concepts that might inspire you to discover a feature you were not aware of yet!
  • In a previous article I described how to configure an Azure SQL database failover group for high availability across multiple regions. But what if you want to limit network traffic to a database in this failover group to only your private networks? In this article I show how to make a SQL database failover group reachable via the Private Link service and make sure the database stays reachable after a failover.
  • Last week I received an invitation for a social work meeting about "Pixel art in spreadsheets". I thought: "How hard can it be". Well, it is about 25 lines of C# 9.0 hard! 😁
  • With an Azure SQL Database, Microsoft is already providing high availability with an SLA of at least 99.99%. But if you want to prevent to be affected by a large regional event or want to meet regulatory demands to be able to execute failovers to another region, enabling a failover group is the solution for you. In this article I will show you how to create a SQL database failover group in two regions using the Azure CLI.
  • To capture images in my applications, I use the VideoCapture class of the EmguCV library, an OpenCV wrapper for .NET. To choose a specific camera, you need to supply an index value. But getting this number is not straightforward, and as this number can change over time, it might break your application in the future. So, what if we could use the actual name of the camera instead of the index value? In this article I will show how to achieve this.
  • I had the honor to be a guest at the dotnetFlix channel, hosted by Sander Molenkamp and Edwin van Wijk. I share more on the techniques, frameworks and libraries I have used and I finish with a demonstration of the finished application. As there was so much to share, it did not fit in a single episode, so we recorded three parts!
  • A couple of my recent articles were about machine learning and image classification in C#. These posts were the results of a pet project on which I was working. I will be speaking about this project at a couple of events in the coming weeks.
  • Recently I wrote an article about getting all prediction scores from your ML.NET model. So, when we want to do this for an ONNX model we have loaded with ML.NET, that should work the same, right? Not really. Depending on the version of ML.NET, the data types of the downloaded Azure Custom Vision ONNX model are very hard to map on the .NET data types we use. In this article I will show how we can get the labels and scores from an ONNX model prediction in C#.
  • When predicting with an ML.NET model you trained yourself, you might be interested in just more than the highest scoring label. But how do you get the other labels and their corresponding scores? In this article I will show how to you can get these values.
  • YAML is a data serialization standard that is intended to be human friendly. For example, it reduces the use of delimiters quite drastically compared to other formats like JSON. Some YAML file authors might push the boundary for readability even further by having a property where the value can be a sequence with zero or more values, or just a scalar if there is only a single value. Reducing the number of delimiters someone has to read or write even further. How can this work with C#, a strongly typed language?
  • When you have created a machine learning model, you will retrain that model when new data is available. But when I recently added a couple of images to the training set of my own ML.net model, I was faced with the following exception: System.InvalidOperationException: 'The asynchronous operation has not completed.' The application did work for weeks, so what has changed? And more importantly, how to fix this situation?
  • The Custom Vision service is one of the Azure Cognitive Services that is provided by Microsoft. With custom vision, you can train a model with your own image data. The portal provides a Prediction API for the trained model to classify an image you supply. There can be reasons why you might not want to use the online REST endpoint and you could prefer an offline model. To work with machine learning in .NET, we can use ML.NET. There are several tutorials how to use this framework. But none of them combine the use of the Bitmap class with a downloaded ONNX model from the custom vision portal. In this article I will walk through the steps to set up an application to classify bitmaps using a custom vision model with ML.NET.
  • When trying to have an application work with an ONNX model I downloaded from the Microsoft Custom Vision portal, I got the following exception: TypeInitializationException: EntryPointNotFoundException: Unable to find an entry point named 'OrtGetApiBase' in DLL 'onnxruntime'. Searching for the error online did not yield any solutions. After solving the problem, I wanted to share the solution for anyone else running into the same exception.
  • Recently, I was using a YAML file for storing some data for a pet project. To work with this YAML in a .NET application, I use the excellent YamlDotNet library by Antoine Aubry. One of my properties was a URL. Deserializing went fine, but when serializing back to a YAML file, things were not going as intended. In this short article, I will explain how I did fix this.
  • This post will be about a new sample of using “Sandboxable”. We will walk through the steps to create a Microsoft Dynamics CRM plug-in that on deletion of any record, stores the deleted data as a file on Azure blob storage.
  • A while back I've introduced Sandboxable. It's a means to use NuGet packages that normally are not available for code that runs with Partial Trust. In this post, we will walk through the steps to create a Microsoft Dynamics CRM plug-in that will add a message to an Azure queue.
  • I would like to introduce to you Winvision’s first open source project: Sandboxable. Sandboxable enables your project to utilize functionality provided by other (Microsoft) libraries that normally are not available in a Partial Trust environment like the Microsoft Dynamics CRM sandbox process. The project offers modified NuGet packages that will run with Partial Trust.
  • This week I’ll be attending the Microsoft Build 2016 conference in San Francisco. Lots of news to be expected for developers covering the many technologies Microsoft is putting on the market.
  • Recently I got certified by Microsoft as Solutions Developer for the Windows Universal Platform by taking two exams that are currently in beta. Because the exams are in beta there is not much guidance to be found online. I noticed during the exams I was being tested on skills not mentioned on the Microsoft Learning web site. In this post I’ll cover these differences and how I prepared for the exams so it’ll be easier for you to get certified.
  • This is the second part in a series of posts about reducing the amount of data transferred between ASP.NET Web API or Azure Mobile App Service and the (mobile) client. In this post we will squeeze a little bit more from our DTOs (Data Transfer Objects).
  • Not long ago I wrote a blog post about Responsive Pivot Headers in Universal Windows Platform apps. Paul responded to this post asking how to change the background of the selected item, just like the example I posted on top of the post. It's a great question and I'm sorry I didn't cover this part so the pivot looks more like the example image. An omission I want to correct with this blog post.
  • These days JSON is used a lot. For storing data, for storing settings, for describing other JSON files, and often for transporting information between server and client using DTOs (Data Transfer Objects). Recently I was monitoring the data transferred from one of my own Web API controllers to a mobile app. I discovered the amount of data transferred was way more then expected. This inspired me try to reduce the size of the transferred data. In this and following blog posts I will describe the different options you can use and combine. You can download the source code at the end of my article.
  • For a Universal Windows App I wanted to implement a Pivot. Reading the guidelines for tabs and pivots by Microsoft I got inspired by the examples given. However, no code samples are supplied so there is no indication how to actually create this in your own Xaml app. In this blogpost I will show the different steps to get the basics done and I will supply the source code for you to use.
  • I received a couple of comments on my article about making the pull-down-to-refresh work with a Windows Phone virtualizing list control. The problem was that the functionality stopped working after navigating away from the page containing the ItemsControl. Today I committed the code to GitHub to fix this issue.
  • The other day I was working on a Windows Phone app. I wanted to add a "pull down to refresh" panel to a large list of images. Just like the Facebook and Twitter apps have. As Microsoft does not provide this functionality in their default controls I started searching the web if somebody else has build something like this already. I found a blog post by Jason Ginchereau where he provided this functionality for Windows Phone 7. In my app I use an ItemsControl with a VirtualizingStackPanel to prevent memory issues. After I added the PullDownToRefreshPanel control to my list and started testing it on my phone, I ran into some issues. In this blog post I will describe my contributions to fix these 2 issues and I will supply the source code for you to use.
  • With Windows Azure we can use Windows Azure SQL Database service (formerly known as SQL Azure) when we need a Relational Database. Microsoft offers a 99.9% monthly SLA for this service. But Microsoft doesn't provide you with the service to restore your data to a moment back in time when you (accidentally) delete of corrupt data. To have a backup in time I wrote some code to allow a Worker Role to backup my Windows Azure SQL Database every hour. Most solutions you find online are relying on the REST Endpoints but the address of the endpoint is different depending on which datacenter your database is hosted. I found a different solution where you only need the connection string to your database using the DacServices.
  • When writing .NET code to access a SQL database we often rely on the Entity Framework (EF). The EF makes it very easy to retrieve data from the database by generating a SQL Query for us. But we should not trust it blindly, as the EF can also generate a bad query. It will return the correct data yes, but at what performance cost?
  • Recently I worked on an HttpHandler implementation that is serving images from a backend system. Although everything seemed to work as expected it was discovered images were requested by the browser on every page refresh instead of caching the browser them locally. Together with my colleague Bert-Jan I investigated and solved the problem which will be explained in this post.
  • With the introduction of LINQ the difference between writing code for accessing a lists of objects in memory and accessing a list of data in an external data source like SQL is vanishing. Combining a in memory with a external list in a single query was not yet possible. With the introduction of .NET Framework 4.0 this has changed.
  • With SharePoint 2010 the amount of databases on your SQL server has grown quite a bit. By default most of these databases have their recovery model set to 'FULL'. After some time you will discover you're running out of space.
  • With the launch of Visual Studio 2010 this week a lot of people will start upgrading to the new version. After the installation was complete I noticed the Surface project and item templates were not available. In this post I explain how to get the entries in Visual Studio 2010.
  • The past couple of weeks I'm working with Silverlight controls embedded in SharePoint 2007. For one of the controls I need to retrieve the data using the Search Query Web Service. This was working perfectly in the development environment. But when deploying the control to the production environment it didn't work.
  • On CodePlex you can find the “MOSS 2007 - C# Protocol Handler” project. When working with the code I discovered 2 issues which I both fixed. Both solutions are summarized here.
  • I was working on some old code which created three DropDown controls with hours, minutes and seconds. I wanted to LINQify it using the LINQ Range method.
  • While working on a project with some existing code I noticed the developer did write large portions of code to get from an URL to a SPList. He probably didn’t know some of the hidden gems in SharePoint.
  • Sometimes you have to split your code into different assemblies. For example when I created a custom Admin Page which inherits from WebAdminPageBase (Microsoft.SharePoint.ApplicationPages). The problem with Microsoft.SharePoint.ApplicationPages is that it's not deployed to the GAC. When compiling you will get the following message: “CS0122: 'foo.bar.x' is inaccessible due to its protection level” Now you have only one choice: make x public. Or maybe not?
  • Lately I am working a lot with LINQ and al types like LINQ to XML, LINQ to XSD, LINQ to objects, etc. Today I had to build some functionality in SharePoint where I had to split users in 2 groups based on a profile property in their User Profile. In this post I will show you how I did this.
  • To deploy our code, we create MSI installers using Visual Studio. One problem I encountered is that there is no property available in code to know where the user has chosen to install the application.
  • When building custom Project Server Event Receivers the result is a dll file. Using app.config and the ConfigurationManagement class will not work. Well actually, it’s possible!