Creating Custom Libraries

  • Thread starter Thread starter Aaron
  • Start date Start date
A

Aaron

I'm coming from C++ programming 5 years ago into VB.NET, so please be
patient with me. In C++, I was able to create a "library" of functions
and procedures that I would commonly use in various projects and
simply "include" them when compiled. In my VB.Net web applications, I
have several functions and methods that I will call on each page, but
I don't want to copy and paste it for each page that uses it. Because
then I may have to change something a dozen times and that is not
manageable. I've searched MSDN and various Usenet groups, but nothing
comes up which means I am probably using the wrong words to describe
the problem. Could someone point me in the right direction? Thanks in
advance...

-A
 
Aaron,

You will probably want to build a class library (File, New, Project, Class
Library). Build your classes with their members here and compile it. Then
you can add that assembly ("library") as a reference to your web application
by right-clicking on Reference and adding. It will come up with a list of
assemblies from the Global Access Cache. Down below it has a button to
browse for an assembly. Find and select your assembly and click OK and you
will see it listed under References in your web application now. Now in
your code-behind classes for your web aspx pages, you can:

Private objMyStuff As New MyAssembly.MyClass

and access all the members just as you would in any other library.

HTH,

Raymond Lewallen
 
Addition to Aaron answer:

For source libraries (non compiled):
Create as many Classes, Modules, or what ever you need
Place your libraries in your personal Library path
When you need to use them add them as a link to you project

For compiled libraries (probably dlls)
Compile your libraries
Place your libraries in your personal Library path
In the Object Browser use customize to add "#includes"
or
in the Solution Explorer window right click References and Add what
ever you wish


WARNING:
Using DLLs probably will allow other people to use your libraries.


Can you answer my question in the thread:
C to VB: meaning of ":" is structures
?
Thanks
 
In response to the first reply:
I do not have the option to choose "Class Library" when I open a new
project. I am running VS .NET 2003 but a class library isn't on the
list. Is there another option? Or how can I add that feature?

To the second reply:
Where would I find my "personal Library Path" and how do I link to it
within the code? As to your other thread, I don't have an answer for
you... sorry

-A
 
Wow, moving from C++ to VB.NET? Brave, very brave. Anyhew, File > New
Project there you can select a Library. Shouldn't have changed for 2k3.
You can do the same if you want to add it to your current soluton, right
click on the solution > Add > New Project. One thing to remember, you can't
export functions from managed code, so no nifty API programming, but, you
can create a plugin system using either Interfaces or Late-binding. Not on
your topic, but something to think about if you're used to making libraries
with C++.
My first comment is because I started out in VB6, then moved to VB.NET,
and now am trying to learn some stuff I need to accomplish in unmanaged
code, so C++ is my choice, but, damn there's alot of stuff in there! LOL

Anyhew, hope this helps,
Sueffel
 
Back
Top