Re: How to create a single CLASS file that will be available to ANY PROJECT I want to link it to???
- From: "Andrew Faust" <andrew@xxxxxxxxxxxxxxx>
- Date: Mon, 5 Nov 2007 18:25:35 -0700
When you create a new Project just select Visual Basic->Windows->Class Library
This will automatically create a dll. You can then reference this Dll (using Add References) from any other project. Your new project can reference anything that was made public from that DLL. This will end up making a copy of your dll for each project, however, if you only want one copy you need to use the GAC.
To use the GAC you need to create a strongly typed assembly. You can google GAC & Strongly typed assembly and you'll get plenty of examples.
--
Andrew Faust
andrew[at]andrewfaust.com
http://www.andrewfaust.com
"Alan Mailer" <clarityassoc@xxxxxxxxxxxxx> wrote in message news:bi9vi31va2cbdtboupoa6o1hb72ejh4ucj@xxxxxxxxxx
Scott, thanks for the advice. Could you either talk me through a
step-by-step way of going about your suggestion... or perhaps
recommend a book or website that might provide this?
Again, I'm new to VB.net and (for well or ill) did not handle things
the way you suggest in my VB6 days.
Thanks again for any feedback.
On Mon, 5 Nov 2007 17:04:00 -0500, "Scott M." <s-mar@xxxxxxxxxxxxx>
wrote:
You are correct that a copy of the .vb file is being made. This is because
VB .NET projects have to have a master project folder that all project items
will be inside of (including sub-folders you may wish to make inside of the
project folder). You can't just have random files that are outside of the
project directory structure be part of your project.
Having said this, IMHO, you are going about this all wrong.
Rather than keeping a source code file hanging around (and getting copies
created each time you want to use it), why not just compile your general
purpose code into a .dll, install that assembly into the GAC and then you
can reference that library from any other project you wish to (without
having to make copies of the .dll). If you wanted to extend the code, you
can simply use inheritance to do that.
-Scott
"Alan Mailer" <clarityassoc@xxxxxxxxxxxxx> wrote in message
news:f5tui35bi6gdn5fbkvfqc01m9rd4u4g4v1@xxxxxxxxxx
Again, I'm new to VB.net and there is something I need help with:
Like (I assume) many of us, over time I want to be able to create some
VB.net classes that I might want to use in more than one Project. So
let's say I've created a Folder called "MyVBNet Classes" to hold these
general-use VB.Net class files that I will eventually associate with
various Projects I create. Now let's imagine I've created a class
called "MyClass.vb" that I've placed into the "MyVBNetClasses" folder.
Let's also assume that, over time, I will be adding code to
"MyClass.vb", but the new code will never be written in a
Project-specific manner. In other words, I will only add code to
"MyClass.vb" that will keep it capable of providing general-use to any
Project that may need it.
My assumption has been that if I create a new project and want to
utilize my general-use "MyClass.vb" class in the project that I just
Right-Click the Solution in my new project's Solution Explorer, click
Add, click Existing Item, and then go to the "MyVBNet Classes" folder
and select "MyClass.vb" from it. So far so good...
...except that what this seems to result in is a copy of "MyClass.vb"
is created in my current Project's folder.
This (I think) is a problem. As I've said, I'm very careful to alter
this type of general-use class file in such a way that it won't become
project-specific; because I want to be able to drop this class where
needed into any project.
But, as I say, the process I've described above seems to create a new
separate and distinct "MyClass.vb" file. Presumably, if I make any
changes to that class while I'm working in a Project, I will ONLY BE
ALTERING THE VERSION of "MyClass.vb" that is in *that particular
Project's folder system*.
I hope somebody will tell me I'm doing this wrong because, given what
I've stated above, this defeats the whole purpose of being able to
create single general-use Classes that will get improved over time but
will be commonly available to any Project I begin to create.
That said, what am I doing wrong here?
Thanks in advance for any help.
.
- References:
- How to create a single CLASS file that will be available to ANY PROJECT I want to link it to???
- From: Alan Mailer
- Re: How to create a single CLASS file that will be available to ANY PROJECT I want to link it to???
- From: Scott M.
- Re: How to create a single CLASS file that will be available to ANY PROJECT I want to link it to???
- From: Alan Mailer
- How to create a single CLASS file that will be available to ANY PROJECT I want to link it to???
- Prev by Date: Re: What is the perfect application model?
- Next by Date: Re: Missing Oracle services after systemced recovery
- Previous by thread: Re: How to create a single CLASS file that will be available to ANY PROJECT I want to link it to???
- Next by thread: Re: How to create a single CLASS file that will be available to ANY PROJECT I want to link it to???
- Index(es):
Relevant Pages
|
Loading