Using interface in Visual Basic

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: hawkon (hawkon_at_discussions.microsoft.com)
Date: 07/11/04

  • Next message: Randy Birch: "Re: centering a form"
    Date: Sun, 11 Jul 2004 07:04:01 -0700
    
    

    Hi,

    I've been reading in MSDN about using Interfaces with Visual Basic (oop similar programming). I have created a vb project based on a sample I found.

    I have made one class with definitions (IDog) :

    ' IDog expresses behavior of a dog object
    Public Property Get Name() As String
    End Property

    Public Property Let Name(ByVal Value As String)
    End Property

    Public Sub Bark()
    End Sub

    Public Sub RollOver(ByVal Rolls As Integer)
    End Sub

    Public Function MyTest()
    End Function

    On properties for this class I have put Instancing = PublicNotCreatable.

    I have made another class with code for this functions. Goes like this :

    Option Explicit
    Implements IDog

    Private Name As String

    Private Property Let IDog_Name(ByVal Value As String)
      Name = Value
    End Property

    Private Property Get IDog_Name() As String
      IDog_Name = Name & "_test"
    End Property

    Private Sub IDog_Bark()
      ' implementation
    End Sub

    Private Sub IDog_RollOver(ByVal Rolls As Integer)
      ' implementation
    End Sub

    Private Function IDog_Mytest()
      IDog_Mytest = "Testing this..."
    End Function

    And finally a asp file calling the dll :

    set objTestCom = Server.CreateObject("MyServer.IDog")

    Response.Write objTestCom.MyTest()

    objTestCom.Name = "JHA"

    a = objTestCom.Name

    response.write a

    Response.End

    In Visual Interdev everything seems to work since a popup box with mehods appears on the instance of the dll object. But the only thing I get is an error saying :

    Cannot launch out of process component

    /testweb/Default.asp, line 18 (Server.Createobject line)

    Only InProc server components should be used. If you want to use LocalServer components, you must set the AspAllowOutOfProcComponents metabase setting. Please consult the help file for important considerations.

    To correct this I've tried to insert :

       <%
         Set WebServObj = GetObject("IIS://LocalHost/W3svc")
         WebServObj.Put "AspAllowOutOfProcComponents", True
         WebServObj.SetInfo
        %>

    But then I get that access denied on the first line with the GetObject.

    So therefore I'd like to know know what I have to do to make vb components with interfaces work in ASP applications.

    In advance thanks a great deal for your help!!

    Kind regards,

    Jon Haakon

    -- 
    ------------------------------
    Jon Haakon Ariansen
    System Consultant
    

  • Next message: Randy Birch: "Re: centering a form"

    Relevant Pages

    • Re: set fontsize with variable
      ... Public Function MsgBoxDLL(Optional strPrompt As String, ... Private m_Prompt As String ... Public Property Let Prompt ... Private Sub cmdButton1_Click ...
      (microsoft.public.vb.general.discussion)
    • Re: Is there a way to prevent a RichTextBox from scrolling?
      ... Private _isRegex As Boolean ... Public Sub New(ByVal thispattern As String, ... Dim entry As tDict ...
      (microsoft.public.dotnet.framework.windowsforms.controls)
    • Re: FileSystemWatcher advice required please
      ... Private ArchiveImport As String ... Private FilesToProcess As ProcessFiles ... Public Sub Main ... Dim NoVersion As New Collection ...
      (microsoft.public.dotnet.framework)
    • Project Error
      ... Private Declare Sub Sleep Lib "Kernel32" ... Dim strDataSrc As String ...
      (microsoft.public.vb.bugs)
    • Re: Collection disappearing at run time
      ... the Tab so that it doesn't take any arguments. ... > Private _tabHeight As New Unit ... > Public Overrides Property HeightAs Unit ... > Protected Overrides Sub OnInit ...
      (microsoft.public.dotnet.framework.aspnet.buildingcontrols)