none
'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)
            OnCreated()
        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,

    Welcome!

    To tell you truth, I'm not good at VB.net. I'm not sure this link could help you: http://blogs.lessthandot.com/index.php/DesktopDev/MSTech/vb-net-and-c-the-difference-in-oo-syntax-3

    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
    Moderator
  • 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.

     

    Thanks

    Saswati


    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@live.com.

     

    Thanks

    Saswati


    Saswati Sanyal Blog : http://saswatisanyal.blogspot.com/
    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