?
Solved

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

Posted on 2008-10-03
6
Medium Priority
?
3,813 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

801 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