Sharing classes

D

dbcuser

Hi All,

This is a very simple question. I have a proxy class (for web service)
and couple of other classes that are common for 3 of my projects. As a
developer, I would like to keep these common classes seperatly and use
them in three different projects. How can I do that?

Thanks.
 
J

Jon Skeet [C# MVP]

This is a very simple question. I have a proxy class (for web service)
and couple of other classes that are common for 3 of my projects. As a
developer, I would like to keep these common classes seperatly and use
them in three different projects. How can I do that?

Create a class library project, put the common classes in that, and
then reference that project (or the DLL it produces if you want it in a
different solution) from the projects which need to use it.
 
B

Bela Istok

You can create a link to the file and have the file in a common place, you
do this when you do in Visual studio, Add Existing Item... dialog, see the
add button, the button have an arroy in the rigth, click the arroy and
select Link, the file that have the link will be in the shared location, and
you can edit the file from the 3 projects.

Regards,

Bela Istok
 
N

Nicholas Paldino [.NET/C# MVP]

This is fine if the types in these shared classes are not passed across
the web service boundary. If they are, then you are going to have problems
with the Xml Serializer, most likely, and modifying the proxy to use the
shared classes.

The easy way to get around it (although tedious), would be to refactor
the classes passed across the web service boundary into interfaces. Then,
in the proxy on the client side, have the proxy class generated by the WSDL
implement the interface, exposing the properties/fields for the class.
Then, you can have your routines work on implementations of the interface.

Hope this helps.
 
T

Tony

I could be wrong.. but it sounds like you are wanting something like a BLL
(Buisiness logic layer) or a DAL(Data access layer). It really depends on
what your classes do. You can search the internet for examples of NTier
applications and you should see several good ones.

Either of the 2 layers I mentioned would basically become a DLL that is
accessible to all of your applications however, following the NTier model
can and usually will cause perforance hits in an application...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top