'My.MySettings' is not accessible in this context because it is 'Friend'. RRS feed

  • Question

  • I have a linq dbml file that have this piece of code in the linq designer file..
         Public Sub New()
            MyBase.New(Global.MySettings.Default.DBConnectionString, mappingSource)
        End Sub
    But when I try to compile I get this error...
    'My.MySettings' is not accessible in this context because it is 'Friend'.


    Why is that, the file is generated by VS 2010....

    Thursday, July 21, 2011 7:26 AM

All replies

  • Hi magmo,


    To tell you truth, I'm not good at I'm not sure this link could help you:

    Thanks for understanding.

    Have a nice day.

    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, July 22, 2011 2:25 AM
  • Hi Magmo,


    It looks like, the problem occurs because the control in the referenced class library is declared with Friend modifiers. You cannot inherit Friend variables from one assembly to another. Therefore, you cannot add handlers for Friend controls from another library in the inherited form.



    You can try the following To work around this problem, set the access modifiers of the control as Public o... work around. Set the access modifiers of the control as Public or Protected in the base form. To do this, follow these steps:

    1. Open the class library project in Microsoft Visual Studio.
    2. Right-click Control on the form, and then click Properties.
    3. In the Properties window, locate the Modifiers property.
    4. From the Modifiers list, click to select Public or Protected.
    5. On the Build menu, click Build Solution.

    Please let me know if the above helps or you need more clarification on the same.




    Saswati Sanyal
    Friday, July 22, 2011 3:20 AM
  • Hi Saswati


    I don't have a form that I can right-click on to change any modifiers, I get the error in the linq to sql dbml designer file.

    Friday, July 22, 2011 5:54 AM
  • Hi Magmo,


    Thanks for your reply. Can you please send the detail of your code? If you want you can directly send it to me at




    Saswati Sanyal Blog :
    Monday, July 25, 2011 5:36 AM
  • Old post... but I was converting an old VB project and ran into this so I thought I would add a solution for any people googling.

    Go to Project>Properties>Settings, and at the top, change the access modifier from friend to public.

    Friday, August 5, 2016 7:12 PM