My business class methods are not being exposed in my presentation layer :(

L

Learner

Hi there,
I am just trying to set up 3 tier architecture. When i add my
Datalayer project to the Business layer project the methods are exposed
to in my business class. But in the similar way when i add the
Businesss layer project to my presentation i don't see the methods of
BL exposing in my presentation layer. But i see the namspace and also
the class of my business class but i don't see the methods!

is there any thing i am missing here?

Thanks
-L
 
K

Karl Seguin

Not sure about your level of experience with OO programming, so forgive me
if these are foolish questions. Are you creating an instance of your
classes? Are all the members of your DataLayer shared/static?

Karl
 
L

Learner

I have used Shared key word in the function definition in Data layer.
Thats why these methods are being exposed in the Business layer. The
functions in the Datalayer just retrieve the connection string from the
web.config file. And the other method just helps to add parameter to
the stored procs. For both of these two functions i have Shared
keyword.


Where as in Business layer i haven't used Shared Keyword so they are
not being exposed in my presentation layer.

I am just wondering just adding the Business layer dll to the
presentation layer references can't i make them available in my
presentation layer?

Thanks
 
K

Karl Seguin

They are, but since your methods aren't shared, you need to create an
instance of your class.

dim mybusinessLayerObject as new BusinessLayerObject()
mybusinessLayerObject.METHOD

These are fairly basic concepts, so you might search for OO resources

Karl
 
L

Learner

Hi Karl,
I was able to expose my BL methods in my presentation layer now. But i
have a question. I havn't had to use Shared key in my BL and i am still
be able to expose them in my PL. But I couldn't expose my DL methods in
BL if i took off the Shared key word in the function defintition in my
DL. Why is that is there any basic concept i need to know about?

Thanks
-L
 
K

Karl Seguin

I'm not sure, but I think that you are associating the keyword "shared" with
actually SHARING your code. That isn't at all the case (and one of the
reasons I prefer the c# keyword "static").

What really controls the accessibility of your code is the access modifier
(public, protected, friend, protected friend and private). That controls
the visibility of your code if you want.

Shared/static is something completely different. Methods that are shared
don't need to have an instance of a class created. Non-shared methods only
work against an instance of a class.

Take for example the string class.

ToUpper() IS NOT a shared method. You need an actual string to implement
it.

Conversly, Format IS a shared method. You don't use it against an instance,
but rather call it directly (string.Format("aaa", "..."))

Maybe you should do some reasearch on the shared keyword.

Karl
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top