Solved

VB.NET 2.0 error Not accessible in this context because it is Friend.

Posted on 2008-10-03
6
3,775 Views
Last Modified: 2012-05-05
I've refferenced a VB6 OCX and I'm calling it with this code:
Imports ORDSABRE_Host

Partial Public Class _Default

    Inherits System.Web.UI.Page
    Protected WithEvents litOne As System.Web.UI.WebControls.Literal

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim SABRE As ORDSABRE_Host.Host
        SABRE = New ORDSABRE_Host.Host

        Dim varResponse As Array
        Dim X As Integer



        SABRE.Area = ""
        SABRE.ID = ""
        SABRE.Suffix = "."

        SABRE.Password = "SEP2008"
        varResponse = SABRE.Send("RES", "G*46", True)
        For X = 1 To CInt(varResponse(0))
            Debug.Print(varResponse(X))
        Next
    End Sub

End Class

I can dim the object and see its methods and properties but it asks me to set the object. When I set the object I get the 'Friend' Error. Whats up.

Chuck
0
Comment
Question by:Chuck_aa
  • 3
6 Comments
 
LVL 8

Expert Comment

by:rlh68
ID: 22642690
Does it expect you to set the property directly, may be it has a set method? Or does it have a constructor that accepts the property in question, it may bypass the friend issue.
 
0
 

Author Comment

by:Chuck_aa
ID: 22659282
I think you'll have to come down to my level. I'm not an expert in VB.net only in VB6. I have no idea what you're talking about.

Chuck_aa
0
 
LVL 8

Expert Comment

by:rlh68
ID: 22695407

I don't know anything about this OCX, but may be you cannot set the object using,

SABRE = New ORDSABRE_Host.Host

because the New routine is scoped as Friend in the OCX. If so, then may be there is a method to set or initialize the object, something like,

SABRE = ORDSABRE_Host.Host.CreateInstance

I don't know what the method's name would be. 'CreateInstance' is something I have seen used.


0
 
LVL 8

Accepted Solution

by:
rlh68 earned 500 total points
ID: 22695415
The idea being that you cannot create the object directly, but instead you set the properties for the object and tell the object to give you an instance based on its properties.

If you are aware of design patterns then think of a Singleton pattern.
http://www.dofactory.com/Patterns/PatternSingleton.aspx

Again, I don't know what your exact issue is or if I am on the right track, but this is what I would be checking.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question