Solved

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

Posted on 2008-10-03
6
3,769 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
Comment Utility
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
Comment Utility
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
Comment Utility

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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now