Archive for category: Uncategorized

Things mom never told you about C++ CLI

03 May
May 3, 2013

For the last few months I’ve been working on a project that utilizes C++/CLI to bridge some legacy code with new code written in C#. A good chunk of that time has been spent running repeatedly into walls, pitfalls, quirks, and “known issues.” I figured I’d document some of the issues I’ve encountered in case someone out there to hopefully save people out there a few hours of frustration.

0) Preparation

  • The following are the books I’ve located dedicated to C++ CLI. The biggest problem with these books is they cover very simple scenarios and assume things “just work” when in reality they DON’T quite often and you end up on Google and Stack overflow trying to figure out some cryptic error message.

1) Avoid Visual Studio 2012 Update 2

If you’re doing C++/CLI work Update 2 is the devil! It breaks the mixed mode debugger. Relevant links:

As a side note, XP Compatibility compilation is now broken:

And last but not least uninstalling Update 2 *may* leave your Visual Studio install crippled:


1) Compile time and link time errors

Some of these could depend heavily on exactly what you are doing so though you may get the same error you may have a completely different problem/solution. Contact me if you have an issue+solution you’ve discovered and want added.

A) Error: “String cannot be of zero length. Parameter name: frameworkName”

Cause: incorrectly created file located at C:\Users\YOURNAME\AppData\Local\Temp\.NETFramework,Version=v4.0.AssemblyAttributes.cpp

Fix1: The file should be written every build, so just delete teh file

Fix2: Open the file and confirm first parameter is empty string ( L""). If so then add appropriate framework to first parameter, as shown below in red:

#using <mscorlib.dll>
[assembly: System::Runtime::Versioning::TargetFrameworkAttribute(L".NETFramework,Version=v4.0", FrameworkDisplayName=L".NET Framework 4")];

Answer found here:


B) Error: “String cannot be of zero length. Parameter name: frameworkName”

Cause: incorrectly created file located at C:\Users\YOURNAME\AppData\Local\Temp\.NETFramework,Version=v4.0.AssemblyAttributes.cpp


17 Oct
October 17, 2012

Derping around a GUI is all fine and good for many things but sometimes you really just need to get things done and your GUI just won’t cut it. Having a powerful command line interface and being knowing how to use it are critical skills. I’ve recently found myself having to use the command line a bit more than usual, so below are some of the learned or re-learned tidbits of knowledge that might help others.

Note: I’m a Windows developer, but the commands below all use bash in Cygwin.

Q: How can I generate a file of an arbitrary size with random data?

A: Use dd in conjunction with /dev/urandom

# 2 Megs
dd if=/dev/urandom of=a.log bs=1M count=2

# 2 Gigs (1 Meg * 2 * 1024)
dd if=/dev/urandom of=a.log bs=1M count=2K 
Note that 1kB = 1000 and 1K = 1024, 1MB = 1000 * 1000 while 1M =1024 * 1024, and so on.
Credit for this protip goes to the Linux Commando blog:


Q: How can I sort a file, remove duplicate elements, and do it all in-place?

A: sort temp.txt -o temp.txt

Q: How can I pipe the output from foo.exe to bar.exe if bar.exe does not accept input from stdin?

A: The obvious answer is to redirect stdout to a file then use the file as an input parameter.
(Note: md5sum *does* accept stdin input. Ignore that for the sake of the example)

echo -n hello > temp.dat
md5sum temp.dat
rm temp.dat

The command below can skip the intermediate step.

md5sum <(echo -n hello)
I wasn’t familiar with this syntax till recently. I discovered it in this bash redirections cheat sheet:

My Reading List

15 Oct
October 15, 2012

I’ve been on a big reading spree this year. By genre, but otherwise in no particular order:


Coding Related:

Career & Self:


  • Dark Swan Series (Richelle Mead)
    • Storm Born
    • Thorn Queen
    • Iron Crowned
    • Shadow Heir
  • The Wise Man’s Fear (Patrick Rothfuss)
  • A Dance with Dragons (George R.R. Martin)
  • The Farseer Trilogy (Robin Hobb)
    • Assassin’s Apprentice
    • Royal Assassin
    • Assassin’s Quest
  • Southern Vampire Mysteries (Charlaine Harris)
    • Dead in the Family
    • Dead Reckoning
    • Deadlocked


Apparently I’m a blowhard

03 Oct
October 3, 2012

Article on Slate calls out those who love to point out when “Correlation does not imply causation.”


Today I learned: HOWTO trim WinSXS size

10 Apr
April 10, 2012

The C:WindowsWinSXS directory can get way too big for comfort. On my Win2k8 VMWare image it was 10.9 gigs. On a VMWare image that’s just wasted space. After a little research I settled on a few steps to help me trim the fat down to 6.72 GB:

  1. Issued the command: dism /online /cleanup-image /spsuperseded
  2.  Install and run CCleaner
  3. Delete all the files in C:windowswinsxsBackup
I also experimented with WinSxs Lite — but it was taking too long for me to be able to see what a difference it makes. I’ll leave it running overnight at some point and report back. By the way, you’d be crazy to try using WinSxSLite on a real machine. I’m doing it because if it hoses my VMWare I restore with the press of a single button.


Using your domain for OpenID

28 Feb
February 28, 2012

Logging in to Stack Overflow today my curiosity about using OpenID got the better of me. I wanted to use my domain name as my login identifier. I quickly found instructions on using my domain with Google as my OpenID provider but I wanted to use

Turns out the process is really easy. The process is covered here:

You just add the following tags to your page’s head tag.

<link rel="openid.server" href="" />
<link rel="openid.delegate" href="" />
<link rel="openid2.local_id" href="" />
<link rel="openid2.provider" href="" />
<meta http-equiv="X-XRDS-Location" 
    content="" />

Voila! You can now use your domain as your login for OpenID!

WinDBG !locks is broken

27 Feb
February 27, 2012

This is old news, but I just discovered it today.

Apparently WinDbg !locks command is broken in the last stand-alone release of Debugging Tools for Windows. To fix the issue you need to download the WDK or downgrade to the previous version (6.10).

Found via while trying to track down a deadlock. I forgot how fun crash analysis can be . I say that both seriously and sarcastically at the same time. When your tools are broken it can lead to hours of wasted time. 🙁


Personal note for later lookup: MS Symbol server path (for easy pasting):

Dump any spare symbols you need in temp (not a best practice!)

MongoDB Notes

11 Feb
February 11, 2012

Some notes I took as I went through trying to compile the C++ driver for mongodb under win32.

  • Hit up MongoDB C++ Page
  • Downloaded driver linked from Driver Download Page & some other prerequisites
  • Went to C++ Driver Compiling and Linking and scrolled down to Windows
  • Hrm. I’d rather not have to mess with scons … so how do I build the lib?
  • WTF? I want to try including client/mongo_client_lib.cpp in my project but IT’S NOT IN THE FRAKING ARCHIVE!
  • OK. Fine. Let’s fire up git and clone the full git source.
  • Ahh…. ok, found mongo_client_lib.cpp. Why the hell even bother putting up the tar ball?
  • Loaded simple_client_demo into visual studio.
  • Boost missing. Ok .. Let’s set up project to point to proper includes and precompiled libraries
  • Holy shit that compiled.
  • Fired up MongoDB Shell and created a collection.
  • Ran through the debugger. Everything works, but how come code references but in the shell it shows name is just ‘foo?
  • Apparently didn’t need perl regex files? (referenced elsewhere)
  • bo and bob? really?! (in bson seralization class)
Thomas Edison Quote

I have not failed. I’ve just found 10,000 ways that won’t work.

— Thomas A. Edison