Friday, March 10, 2006

C, C#, and Cross Calling

It's actually 3:23 in the morning, but I'm back-dating this post a few hours so it gets listed under the 10th.

Today sucked big time, and I don't know why. Just a bad day. A coworker would say something, and I'd be staring at them blankly, "What..?" Maybe it's the Spanish tapes, but I had some serious trouble comprehending people today. I ran a couple miles during lunch, but I haven't done that since before my vacation in Europe, so I'll be sore tomorrow. I attribute the day to my post-relationship rollercoaster mood swings. Frightening. Maybe I knew I'd have to change a flat tire before going home.

But this evening... that's another story! I played around with C# a bit, trying to figure out how to call managed code from unmanaged C or C++. Everyone and their sister wants to call C from C#, for compatibility purposes with legacy code. However, I want to write a wrapper for Adobe FrameMaker, and I need to be able to call C# code from a C DLL. Without that capability, I might as well stick with the Python wrapper I already wrote and keep fighting the PyWin MFC monstrousity. Unfortunately, google doesn't really understand how "c call c# callback" is any different from "c# callback call c," so searching is really difficult. But, given enough time, inspiration, and dedication...

I got it. Well, actually, I copy-and-pasted, but it's the thought that counts. Damn, I'm good. Now I'm going to turn around and spend two days next week and write hundreds and hundreds of lines of wrapper code, and learn a new language while I'm at it. Ho hum, another day on the job. I love my work!

I also figured out how to compile .cs from the command line, which is worth the price of admission several times over.

0 Comments:

Post a Comment

<< Home