Solved

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

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

Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

691 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