views:

26

answers:

1

I need to be able to write a DLL in either C# or VC++ that is accessible from code that is written in Visual Studio 2003 VC++. It looks like the code is unmanaged (uses * for pointers) VC++ and this DLL needs to be able to drop right in and be accessed by the current code.

The DLL is an RS232 driver that needs to be able to return an int for an error code and pass back, by reference, some measured values, to the calling program.

Will I even be able to write this in C#? If not, I only have access to Visual Studio 2005 or 2008. Will I be able to write my code in either, and will that DLL be able to be called from the current code base? Or do I have to go looking on ebay for a copy of VS 2003?

A: 

An unmanaged DLL authored in C/C++ in VS2008/2005 should work just fine with invoking code in a VS2003 C/C++ project. It's also likely the path of least resistance. If your DLL references other DLL's that aren't likely to be available with VS2003, make sure to either re-distribute them if you can, or link statically otherwise.

A managed DLL is also possible, but will require a little bit of glue code to bridge the managed/unmanaged gap. Make sure to target the .NET runtime version that VS2003 supports (1.1).

Oren Trutner
Hi and thanks for your response,The only issue I have with this is that the calling code is the VS 2003 VC++. The current code has to use my DLL to access a couple of the RS232 functions that I will write in VC++. Will I be able to compile a VC++ unmanaged DLL in VS 2005 or 2008 that can be directly accessed by the VS 2003 code?
John
Yes. The DLL binary format has been quite consistent for many years now (decades, even.) DLLs routinely work across versions of the tools that created them.
Oren Trutner