How to invoke the ClassLibrary?

  • Thread starter Thread starter yxq
  • Start date Start date
Y

yxq

Hello,
I writed some classes(but not a class) in a ClassLibrary and builded a
test.dll file, but how to invoke the test.dll?

'test.dll//////////////////////

Moudle MyTest
Public class A
...
End Class

Public class B
...
End Class

Public class C
...
End Class
End Module

I have referenced the test.dll in my new project, but do not know how to use
Class A, B, C.

Thank you
 
yxq said:
I writed some classes(but not a class) in a ClassLibrary and builded a
test.dll file, but how to invoke the test.dll?

'test.dll//////////////////////

Moudle MyTest
Public class A
...
End Class

Public class B
...
End Class

Public class C
...
End Class
End Module

I have referenced the test.dll in my new project, but do not know how to
use Class A, B, C.

Remove the 'Module' declaration around the classes and simply use the
classes as you would do with classes which are part of other libraries:

\\\
Imports ClassLibrary1 ' Importing the DLL's namespace.
....
Dim c As New C()
....
///
 
If you've referenced the dll for the class library, then just add the Imports
statement to the module or class in which you want to use the library
classes. Then:

dim myClass as New Class A, etc.

However, unless your classes in the Class Library are really tested and
won't need and changes, the easiest way is to add the Class Library project
to your solution in which you will use the Class Library. That way, you can
easily change any of the classes in the class library and/or add to it
quickly within your solution.
 
Add the dll to the project references. You may also need to add the class's
namespace to the 'imports' in your project.

Reference methods from your classes by instantiating them first:

Dim aclass As A = New A

then call methods/properties from the instance:

aclass.myProperty = "something"
aclass.myMethod()

You should be able to bring it together fairly easily - if you can't then
see here:

http://msdn.microsoft.com/vstudio/express/vb/learning/


Troy
 
Back
Top