Miscellaneous Debris

Avner Kashtan's Frustrations and Exultations

Browse by Tags

All Tags » C# (RSS)
Not-So-Lazy Static Constructors in C# 4.0
A coworker pointed me towards an interesting blog post by John Skeet about the changed behavior of static constructors in C# 4.0 (yes, I know, it’s been a few years now, but I never ran into it). It seems that C# 4.0 now tries to be lazier when instantiated...
ArcGIS–Getting the Legend Labels out
Working with ESRI’s ArcGIS package, especially the WPF API, can be confusing. There’s the REST API, the SOAP APIs, and the WPF classes themselves, which expose some web service calls and information, but not everything. With all that, it can be hard to...
Posted: Mar 27 2012, 11:18 AM by Avner Kashtan
Filed under: , , , ,
The Case of the Unexpected Expected Exception
“NUnit is being problematic again”, they told me when I came to visit the project. “When running unattended it’s not catching assertions properly and the test is coming up green, but when stepping through in the debugger, it works fine.”. It’s nice, when...
Moq, Callbacks and Out parameters: a particularly tricky edge case
In my current project we’re using Moq as our mocking framework for unit testing. It’s a very nice package – very simple, very intuitive for someone who has his wrapped around basic mocking concepts, but tonight I ran into an annoying limitation that,...
Static Constructor throws the same exception again and again
Here’s a little gotcha I ran into today – if you have code in a class’s static constructor that throws an exception, we will get a TypeInitializationException with the original exception as the InnerException – so far, nothing new. However, if we keep...
Upgrading all projects to .NET 3.5
A simple macro to change the Target Framework for a project from .NET 2.0 to .NET 3.5, hacked together in a few minutes. This will fail for C++/CLI projects, and possibly VB.NET projects (haven't checked). Works fine for regular C# projects, as well as...
System.Diagnostics.EventLogEntry and the non-equal Equals.
Just a quick heads-up in case you're stumped with this problem, or just passing by: The System.Diagnostics.EventLogEntry class implements the Equals method to check if two entries are identical, even if they're not the same instance. However, contrary...
Displaying live log file contents
I'm writing some benchmarking code, which involves a Console application calling a COM+ hosted process and measuring performance. I want to constantly display results on my active console, but since some of my code is running out-of-process, I can't really...
Another minor C#/C++ difference - adding existing files
Another minor detail that bit me for a few minutes today. I'm posting this so I'll see it and remember, and possibly lodge it in other people's consciousness. Using Visual Studio 2005, adding an existing .cs file to a C# project will cause a copy of that...
Dynamically creating a Sharepoint Web-Service proxy instance
In my current code, I find myself accessing many Sharepoint web services. In one run of code I can access 5-6 different web services on dozens of different sites, not necessarily even on the same server. Given that I find myself writing a lot of boilerplate...
More Posts Next page »