Archive for the ‘ .NET ’ Category

Using System.Data.SQLite under Linux and Mono

If you want to use the lean, mean and fast SQLite database in your .NET programs under Linux and Mono, using Mono.Data.SQLite might seem like the obvious choice, but you can actually do better. With a little effort, you can use System.Data.SQLite under Linux+Mono (and probably macOS too). There a couple of key benefits to be gained from this: Read more

Mpir.NET – NuGet package for high performance large integers

mpirnetlogoMpir.NET is a .NET wrapper for the high performance multi precision integer library MPIR, which in turn is a Windows friendly fork of GMP.

As noted in my previous post, High performance large integers in .NET, it would be highly desirable to have a large integer library that combines the speed of MPIR with the usability of Emil Stefanov’s “GMP for .NET”. The obvious way of doing this, would be to make a fusion of Sergey Bochkanov’s MPIR wrapper for .NET, X-MPIR, and GMP for .NET. Since both Stefanov and Bochkanov have released their code under the LGPL license, this turned out to be possible with a couple of modifications to both code bases. Read more

High performance large integers in .NET

BigNumBench01ThumbWhen you’re playing with the sort of big integers used in, for example, cryptography, 64 bits just aren’t enough. In this post, I’ll compare and benchmark some of the alternatives that take .NET numerics beyond 64 bits. The benchmark results turn out to be a tale of the unexpected, to paraphrase Roald Dahl.

The test case is RSA signature verification, which uses the formula c=me mod n, where c, m and n are the same size as the RSA key (the public RSA key consists of n and e), typically 1024, 2048 or 3072 bits, while e usually is a mere 32 bits (usually holding the value 17 or 65537). In the test, I’ll use a 1024 bit key, because that conveniently enables me to reuse some F# code I wrote to verify RSA signed data written by EU digital tachographs. Read more

A utility to fix faulty ConcurrencyMode settings

As described in the post on EFConcurrencyModeTest, the Entity Framework tools for reverse engineering a database will not set ConcurrencyMode correctly for the column types (rowversion a.k.a. timestamp) used for optimistic concurrency control. Until that bug is fixed, you have to take care if this yourself. I put up with this about twice, before getting bored enough to write a utility that automates it. To paraphrase Terence Parr (ANTLR), why edit by hand in 10 minutes what you can spend an hour automating? Thus, I wrote FixEFConcurrencyModes. Read more

ConcurrencyMode unit tests for Entity Framework EDMX files

When using Microsoft’s Entity Framework, the ConcurrencyMode attribute for properties mapped to rowversion (a.k.a. timestamp) database columns, should be set to ConcurrencyMode.Fixed, to enable optimistic concurrency.

Unfortunately, due to a bug in the Entity Framework tools, you have to do this manually. The NuGet package EFConcurrencyModeTest makes it easy to write the unit tests needed to make sure that you have done so.

Read more

Compatibility between 32-bit, 64-bit and “Any CPU” .NET assemblies

I couldn’t find any decent .NET platform target compatibility chart, so I made one:

.NET platform compatibility charts

Read more