A friend of mine recently proposed the following problem on twitter: Given f y z =108 – (815 – 1500/z)/y, x0 = 4, x1 = 4.25 and xN+1 = f xN xN-1 then what is x80? Note: This might not be as easy as it looks — Mårten Rånge (@marten_range) October 19, 2013 I didn’t…
Category: C#
Bindings for DataGridView hosted in an MFC application
A WinForms DataGridView control has the ability to automatically generate its columns and populate from a specified data source (which can be a DataSet, a simple list or something else). All you have to do is something like this: var list = new List<Record>() {new Record() {Id = 1, Name = “item 1”, Date =…
error C3510: cannot locate dependent type library ” {bed7f4ea-1a96-11d2-8f08-00a0c9a6186d} v.2.4
Problem I have recently migrated a C# 2.0 project registered for COM interop to .NET 4.5 and when I imported the type library in a C++ project with no_registry, suddenly I got some errors because the type library could not be imported. Here are the steps to reproduce: create a .NET Class Library project and…
T4 Lessons Learned
Working with T4 recently I learned a couple of valuable lessons I’d like to share. Lesson 1: Template Language One of the parameters of the language directive is the language, which specifies the language used in the code blocks of the template. Two languages are specified, C# and VB. <#@ template language=”C#” #> However, any…
WinRT and winmd Files
If you tried the Win8 Developer Preview and built WinRT components (native or managed) you noticed the .winmd files. The name stands for Windows Meta Data and the format of these files is the same used by the .NET framework for the CLI, i.e. ECMA-335. That means you can actually read these files with a…
Accessing 64-bit Native COM Server From a Managed Client
Not long ago I ran into a COM interop problem that was a bit tricky to fix. So I’m sharing the problem and the solution here in case others encounter the same problem. I had this native in-proc COM server that initially was built only for x86. It was used in a native MFC application…
Weasel Implementation in C#
In the book The Blind Watchmaker, Richard Dawkins explains how evolution happens through accumulated small random variations (or mutations) filtered by the natural selection, as opposed to the mainstream misinterpretation that evolution happens in big leaps. He proposes a computer program, called weasel, to demonstrate how the accumulated small improvements (mutations that bring a benefit…
Interface Implementation in C#
I recently found a piece of code that can be summarized by the following sample: interface I { void F1(); void F2(); } class X { public void F2() { Console.WriteLine(“F2”); } } class A : X, I { public void F1() { Console.WriteLine(“F1”); } } As you can see there is an interface I…
Using ColorMatrix for Creating Negative Image
.NET provides two classes for image transformations: Matrix, used for geometric transformations, and ColorMatrix, used for color transformations. One of such color transformations is inverting or negating. This means subtracting each color component from 255. Black (0,0,0) becomes White (255, 255, 255), and Green (0, 255, 0) becomes Magenta (255, 0, 255). You can find…
DotNetZip Library
.NET 3.0 provides some support for working with ZIP files. However, it has an important drawback: it only works for packages that are conformant to the Open Packaging Convention standard. Most of the ZIP files are not. Codeplex features a library called DotNetZip that provides support for packing and unpacking in C#, VB.NET or any…