Jump to content
Sign in to follow this  
  • entries
    94
  • comments
    127
  • views
    83586

the value of TDD when using C++ DLLs in a C# app

Sign in to follow this  
Seriema

183 views

(note, I'm using VS.NET 2003)

what a night! WHAT! A! NIGHT!

If I ever "should've written a waterproof testcase", this was it!

Using a unmanaged C++ with a C# app really has its disadvantages! If you don't have a good Test Driven Design that is! Let me give you some real life examples.

[ where's the problem? ]

For one, is the C# System.NullReferenceException.

MSDN says: The exception that is thrown when there is an attempt to dereference a null object reference.

I learned this past week that it really means: The DLL file was not found. The function was not found in the DLL file. The function in the DLL crapped itself.
Yes, either one of those three errors! My tip is set something in the absolute beginning of your function to show that it's actually called, thus making it clear that it's not one of the two first reasons for NullRef.Exc. How do you do that? Read on!

[ how do I get there? ]

hohoho... here's the fun part... YOU CAN'T! You can't step into the function like you can when debugging from a C++ app! HAH! How fun! And OutputDebugString() from a unmanaged DLL doesn't show up in the output window when stepping through your C# app! So how did I do it? Thanx to this little gem, it's freeware. DebugView

It shows OutputDebugString() messages, even when you're not debugging the app! ie. you can have it run in the background while you test out a program that can't be run in debugging mode inside VS.NET (but the program must've been compiled in debug mode).

[ how did you debug it? ]

By adding OutputDebugString() like make-believe breakpoints in my C++ DLL, and watching the text fly by in DebugView. Kinda like programming before you knew what a breakpoint was!

[ what did we learn? ]

if you can't figure that out... re-read! ;)

[ any tips? ]

Yes. Test Driven Design! I'm not kidding folks! If you're only going to make a test case for ONE module in your life, make it this one... Create a uber waterproof C++ test app for your C++ DLL. Remember that all functions promises something/somethings. Like changing a internal value, to something valid. Or returning a pointer on success and otherwise NULL. So check for those stuff to. But a better introduction can be found on this article here at gamedev.

If you're interested, get this book. I know I am...

cheers!
/JP
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!