Click here to Skip to main content
15,746,107 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all , i have private int Webmethod in Webservice file and i want to call it from WebForm . How can i make this ?
I call like this and it doen't work .
protected void Button_Click(object sender, EventArgs e)
        int x = Namespace.WebService1.GetPriv(string a, string b)


' Namespace.WebService1.GetPriv(string , string)' is inaccessible due to its protection level .
Updated 11-Nov-15 20:57pm

1 solution

No, you cannot.
You need to make the method public if you want to access in another project.

The type or member can be accessed by any other code in the same assembly or another assembly that references it.
The type or member can be accessed only by code in the same class or struct.

Access Modifiers[^]
Accessibility Levels[^]

Share this answer
Андрей Голубцов 12-Nov-15 4:00am    
Thanks , first link helps me )
Krunal Rohit 12-Nov-15 4:41am    
Glad I could help. :-)


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