Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a C#.Net dll Class within VB.Net - Basic Problem 1

Status
Not open for further replies.

BDRichardson

Programmer
Jul 23, 2003
46
GB
[sadeyes]
I would appreciate it if someone can resolve my basic problem with calling a Class from a C# dll, from within VB. I have created a very simple Class library within one Solution, and added a reference to it in a VB Project within another Solution. It would seem that I can call the parent class, but not the sub-class.

For example, I can write:
Code:
Dim CustomSubClass As New ParentClass()

But it will not accept:
Code:
Dim CustomSubClass As New ParentClass.SubClass()

All I want to do is make a custom class which I can reference in different projects. This particular one needs to take an input value, perform some simple manipulation, and return the new value.


C# Class:
Code:
// Ignore the underscores - Added for clarity
using System;
namespace CustomClasses
{
__public class ParentClass
__{
____public static string SubClass(string sValue)
____{
______// Some basic string manipulation code
______return sValue;
____}
__}
}

VB Class:
Code:
Imports CustomClasses
Public Class TestClass

__Dim CustomSubClass As New ParentClass.SubClass()

__Public Sub TestSub()
____Dim sNewValue As String
____sNewValue = CustomSubClass("OldValue")
____MsgBox("OldValue is now: " & sNewValue)
__End Sub

End Class

Please help me!
 
Not sure I totally understand...

When you say add a reference, are you adding a reference to the compiled .dll, or are you adding the c# project to the vb solution?

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
Internal classes (sub classes) are only visible to the containing class. If you want to create an instance of it, you'll have to add a method to the containing class to return a copy to your VB caller.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
AtomicChip - Yes, I am referring to a compiled dll, and not adding it.

Chip H - Thanks for your feedback. Would you kindly elaborate, as I'm not entirely sure what you mean.

Thanks
 
Thanks for your help guys. I have managed to resolve it now.

[shadeshappy]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top