Class name conflicts in C# and managed C++ dll in VS 2003
I created a project in .net 2003. In this project, the c# code will call a managed dll which is built by C++. In the dll, it defines some classes whose names conflict with the classes from .net framework.
For example: Stream, Array, in C++ dll and System.IO.Stream, System.Collections.Array in C#.
So, when i compile the project, all the c# code must include the namespace like System.IO.Stream. It is grotty and it is more important that the c# code has been written before the C++ dll and it means enormous and boring work to change the c# code.
I have tried to find and set the corresponding compile options to overcome this problem. But nothing works.
Please help me and any suggestions are appreciated!
AlanPosted Jul 19, 2007, 6:40 AM
Anyway, I'm pleased that you've solved it now :-)
ken duPosted Jul 18, 2007, 10:56 PM
ken duPosted Jul 18, 2007, 9:49 PM
ken duPosted Jul 18, 2007, 9:16 PM
ken duPosted Jul 18, 2007, 8:49 PM
AlanPosted Jul 18, 2007, 2:41 PM
However, if you have access to the Managed C++ source code, then you could simply place everything within a namespace (CPPTypes say) and rebuild the dll.
Them, from the C# side, you could use some 'using' aliases to distinguish between the similarly named types. For example:
using System.IO;
using System.Collections;
using CPPTypes;
using Stream = System.IO.Stream;
using CPPStream = CPPTypes.Stream;
using Array = System.Array;
using CPPArray = CPPTypes.Array;
That way you wouldn't need to fully qualify the .NET framework Stream, Array etc from your code.
ken duPosted Jul 18, 2007, 1:41 PM
AlanPosted Jul 17, 2007, 12:24 PM