Home All Groups Group Topic Archive Search About

How to invoke the ClassLibrary?

Author
4 Apr 2006 10:38 PM
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

Author
4 Apr 2006 11:12 PM
Herfried K. Wagner [MVP]
Show quote Hide quote
"yxq" <ga***@163.net> schrieb:
> 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()
....
///

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
4 Apr 2006 11:17 PM
Dennis
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.
--
Dennis in Houston


Show quoteHide quote
"yxq" wrote:

> 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
>
>
>
Author
4 Apr 2006 11:22 PM
Simmo
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


Show quoteHide quote
"yxq" <ga***@163.net> wrote in message
news:epx%23MiDWGHA.1228@TK2MSFTNGP02.phx.gbl...
> 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
>
>