DLL's & reusable code

  • Thread starter Thread starter johncee
  • Start date Start date
J

johncee

I am pretty new to VB.Net but I felt like I was making pretty good
progress until I branched out into trying to reuse existing code!

I created a "solution" with one project. It has a form with a datagrid
that I'm using to maintain a data file (table) and I thought it would be
good to "genericize" this code so that if I just passed it some info
about a table & it's fields, that the form would work to allow
maintenance on any table I wanted.

This works pretty good. I created a new form in the same project and it
inherits the original form, passing it an SQL stmt and a collection
containing info to process the fields I want. The thing is, I want to
use the "genericized" maintenance form in other applications and I can't
figure out how to do that, or if it's even possible.

When I create the original app, it compiles as an .exe. I've tried
adding it as a reference in a new application, but .net says I can't do
that. I tried creating the original app as a class library, but that
doesn't seem to be allowed either (none of the system.windows objects
are recognized.

I sure don't want to copy the original code into every new app that will
use it. What can i do?

Thanks alot!!!!
 
Looks like you are missing a reference or an Import statement in your class
library project. When something is not recognized does it work when using
its full name (i.e. System.Windows.Forms.Whatever) ?
If it still fails post the exact message you have...
 
You should compile as a class library and then add a reference to the
compiled DLL in you new projects.

Thanks,
Brian
 
Thank you Patrice & Brian. It's great to have experienced people
willing to share their knowledge & time!

I have got it to work and it appears that Patrice's suggestion about the
imports did the trick. The class library project containing my base
class which has the datagrid did not have System.Drawing or
System.Windows.Forms listed as imports in the property page of the
project. Adding them here resolved all the undefined object errors I
had.

The application project I created with the derived class inheriting from
the class library also needed System.Drawing added in the same place (I
was using DataGridTextBoxColumn objects within it).

"Ay Carumba" this problem was tortuous, but I gained fundamental
knowledge about code reusability & I couldn't have done it with out your
help. Thanks again!
 
Back
Top