Difference between background and concurrent garbage collection?

Here, Microsoft uses the names “concurrent” and “background” to describe two versions of the GC it uses in .NET. In the .NET world, the “background collector” is an enhancement over the “concurrent collector” in that it has less restrictions on what application threads can do while the collector is running. A basic GC uses a … Read more

Enum addition vs subtraction and casting

Good question – I was surprised that the first and third lines worked. However, they are supported in the C# language specification – in section 7.8.4, it talks about enumeration addition: Every enumeration type implicitly provides the following pre-defined operators, where E is the enum type and U is the underlying type of E: E … Read more

Workaround for WPF Freezable bug?

To workaround this .net bug, change all of the Solid Color Brushes in your code to be freezeable. For example <SolidColorBrush x:Key=”WindowBackground” Color=”Black” /> should be changed to: <SolidColorBrush po:Freeze=”True” x:Key=”WindowBackground” Color=”Black” />. For more detailed instructions see here: How can WPF objects deriving from Freezable be frozen in XAML?.

Do you need both .net 3.5 and 4.0 installed or just .net 4?

I remember reading something once from Microsoft that stated: “.NET 4.0 adds in-process side-by-side compatibility with earlier versions of the Framework. This feature allows an application process to simultaneously run part of its code using the .NET Common Language Runtime (CLR) 4 and other parts using older versions of the CLR.” So to answer your … Read more

.NET 4, AllowPartiallyTrustedCallers attribute, and security markings like SecurityCritical

You are correct: in .NET 4, leaving the APTCA on there makes the assembly SecurityTransparent, and that may be what’s causing you grief. The MSDN article Migrating an APTCA Assembly to the .NET Framework 4 has a good discussion and explanation of the changes to the AllowPartiallyTrustedCallersAttribute in .NET 4. Specifically: The AllowPartiallyTrustedCallers attribute has … Read more

Getting “” at the beginning of my XML File after save() [duplicate]

It is the UTF-8 BOM, which is actually discouraged by the Unicode standard: http://www.unicode.org/versions/Unicode5.0.0/ch02.pdf Use of a BOM is neither required nor recommended for UTF-8, but may be encountered in contexts where UTF-8 data is converted from other encoding forms that use a BOM or where the BOM is used as a UTF-8 signature You … Read more

How do I convert an IEnumerable to JSON?

IEnumerable<int> sequenceOfInts = new int[] { 1, 2, 3 }; IEnumerable<Foo> sequenceOfFoos = new Foo[] { new Foo() { Bar = “A” }, new Foo() { Bar = “B” } }; var serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); string outputOfInts = serializer.Serialize(sequenceOfInts); string outputOfFoos = serializer.Serialize(sequenceOfFoos); Which produces the output [1,2,3] [{“Bar”:”A”},{“Bar”:”B”}] And then you can get … Read more

Is there a workaround to the C# 28-time inline limit?

I haven’t tested this, but it seems like one possible workaround is to have multiple properties that all return the same thing. Conceivably you could then get 28 inlines per property. Note that the number of times a method is inlined most likely depends on the size of native code for that method (See http://blogs.msdn.com/b/vancem/archive/2008/08/19/to-inline-or-not-to-inline-that-is-the-question.aspx), … Read more