Click here to Skip to main content
15,907,326 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello! I use windows froms C#
I made some layers projects (BLL, MDL, PL, DAL)
At PL I added reference to BLL.
How to request method from BLL now?
BBL.Method does not work
Posted

Hi Junoli,

In order to access methods from BLL, you need to create object for the classes in BLL.
Like below
C#
BLL objBLL = new BLL();
objBLL.YourBLLMethod_Name();

If your BLL contains any static classes then directly you can call the methods in those classes with class name.
Like below
C#
BLL.YourBLLMethod_Name();

Happy coding.

Regards,
Manoj
 
Share this answer
 
HI,

If your layers are in the same project then you can include the folder structure in the Using section and then can able to access the object and methods defined there in the class.

If you are having the different projects for the structure then you can able to access the methods only after including the dlls in the required project and creating the object there as mentioned.

BLL BLLObject = new BLL();
BLLObject.MethodName();


Thanks
 
Share this answer
 
Hi,

When you are adding reference in your project, all the assembly namespace/classes/interfaces will be accessible in your project. In case of namespace classes you need to import namespace in the header class file.

After getting class in your project you can create instance of your class and use the function.

Hope this information helps you,
 
Share this answer
 
I don't get what the other answers are trying to tell you... So I just give you a list of steps involved, and you may can find out what you missed?

* Create a VisualStudio Solution for the related projects
* Add projects
* Add references to the projects depending on another project (add reference dialog/projects)

At this Point you should be able to acccess all PUBLIC classes/methods/... from your referenced assembly (in your example BLL) by FULLY QUALIFIYING them. This means using Namespace.ClassName.Method/Property/... for static things, or by instantiating an object for calling non static members.

If you don't want to type the full name over and over again, you can use a using directive to include the referenced Namespace.

If I have to guess I'd say you maybe
* ... have forgotten to add the correct modifiers (internal, public)to the members you want to access
* ... are confused about static/non static calling
* ... forgot to fully qualify the name of the member to call (=forgot Namespace)

I hope this helps to solve your problem...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900