Scenario:- Consider you are building a C# dll, which is going to be used by .NET client application written in VB .NET. By nature C# is case-sensitive and VB .NET is case-in-sensitive.
Due to this specific casing behavior of these languages, C# has power to declare class members (methods, variables etc) in case-sensitive manner. I.e Deposit(), deposit() and dePosit() are three different methods which can be created in C#.

But this is not how VB .NET works. VB .NET can't allow this because VB .NET is case-insensitive and so can't differentiate that these are three different methods.
Problem:- The problem occurs when the C# dll is being consumed by a VB .NET, and so none of the functionality from C# is exposed to VB .NET, even though its successfully built in C#. Reason of this is that VB .NET don't see those methods of C# as three different methods and so can't decide which one to display in the Intellisense.

Solution:-
The solution of this problem has to take place in C#, because C# has case-sensitive nature.
If you are building a reusable dll which can be easily consumed by any .NET compliant language eveb by those which are not case-sensitive like C# in which the dll has been developed.
You need to enable the CLS Complaince in C# application, by default its set to false.
Once you enable it then any member of a class which differs by case is listed in the CLS-complaince warning.

Now the fix for this is to resolve these CLS warnings and fix the function names, lets rename them rather being different in case only.

After the change in function's name, now there are no member functions in the C# class which differs by case only.
Now VB .NET client can see these functions

No comments:
Post a Comment