How to properly "name" a class library?

  • Thread starter Thread starter Terry Olsen
  • Start date Start date
T

Terry Olsen

I have written a class library that I want to reference from a windows
app. The filename is UPSTrackTool.dll. The Class name is UPSTrackTool.

When I reference it from my windows app, I put the Imports UPSTrackTool
at the top. But when I call any methods I have to use:

UPSTrackTool.UPSTrackTool.MyMethod()

How do I name this thing so I only have to Imports UPSTrackTool and then
I can just call MyMethod()?
 
Terry said:
I have written a class library that I want to reference from a windows
app. The filename is UPSTrackTool.dll. The Class name is UPSTrackTool.

When I reference it from my windows app, I put the Imports UPSTrackTool
at the top. But when I call any methods I have to use:

UPSTrackTool.UPSTrackTool.MyMethod()

How do I name this thing so I only have to Imports UPSTrackTool and then
I can just call MyMethod()?

You need to make sure the root namespace in the settings for your
project is set appropriately. You would then refer to your classes by
this root namespace plus the class name. The root namespace is
typically set to the company name or something like that. It is also
typical to include other namespaces in the code to group classes
together.

For example, suppose the root namespace for the project was set to
MyCompany

Then in your code, you might have the following:

Namespace "DataClasses"
Public Class SomeClass
'Code here
End Class
End Namespace

The program that uses the class library would use an Imports statement
like this:

Imports MyCompany.DataClasses

And then you could use the class as you propose.

Chris
 
Back
Top