#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    1
    Rep Power
    0

    Classic ASP COM Microsoft VBScript runtime error: Invalid procedure call or argument


    Hi Classic ASP Experts,

    I am new to VBScript, COM and Classic ASP. I am getting Microsoft VBScript runtime error: Invalid procedure call or argument, while trying to pass an argument of type class to the COM method call. Although the object is created and the Visual Studio intellisense shows the method name along with parameter. I am not able make procedure call or argument.

    What am I missing?

    Please help.

    Here's my VBScript (ClassicASPHome.asp):

    response.write("My first ASP script!")

    set co = Server.CreateObject("ClassicASPCOM.ComplexObject")
    co.Message = "Messi"
    co.Number = 100


    Dim ccom
    Set ccom = Server.CreateObject("ClassicASPCOM.ClassCOM")


    response.Write(ccom.GetMessage("1234567890"))

    '---------------Works fine till here

    Dim ret

    ' ---------------The following statement throws error

    ret = ccom.PaymentDetails(co)

    response.Write("Fine")



    Code Snippet:

    // C# Code (ClassicASPCOM.dll) built with Strong Name and Registered for COM Interop:

    // Executed the following in Visual Studio Command Prompt in bin\Release folder
    // Regasm ClassicASPCOM.dll

    // Regasm ClassicASPCOM.dll /codebase

    // Regasm ClassicASPCOM.dll /tlb

    // gacutil/i ClassicASPCOM.dll

    using System;
    using System.Runtime.InteropServices;

    namespace ClassicASPCOM
    {
    [ComVisibleAttribute(true)]
    [Guid("D355BC25-B85F-4476-8D38-582F92F7B6F4")]
    public interface IComplexObject
    {
    [DispId(2221)]
    int Number {get; set;}
    [DispId(2222)]
    string Message { get; set; }
    [DispId(2223)]
    DateTime Dtime { get; set; }
    }

    [ComVisibleAttribute(true)]
    [Guid("4E602191-8D09-458E-A0D0-A0A267696F78"),
    ClassInterface(ClassInterfaceType.None)]
    public class ComplexObject : IComplexObject
    {
    int Nmbr;
    public int Number
    {
    get
    {
    return Nmbr;
    }
    set
    {
    Nmbr = value;
    }
    }

    string Msg;
    public string Message
    {
    get
    {
    return Msg;
    }
    set
    {
    Msg = value;
    }
    }

    DateTime Dt;
    public DateTime Dtime
    {
    get
    {
    return Dt;
    }
    set
    {
    Dt = value;
    }
    }
    }

    [ComVisibleAttribute(true)]
    [Guid("4042FE79-8ACA-4E5D-9F14-2FF7C6AE8D88")]
    public interface IGetMessage
    {
    [DispId(2224)]
    string GetMessage(string Message);
    [DispId(2225)]
    string PaymentDetails(ComplexObject cObject);
    }

    [ComVisibleAttribute(true)]
    [Guid("9A133858-5893-4CA7-9048-345CD0FCF535"),
    ClassInterface(ClassInterfaceType.None)]
    public class ClassCOM : IGetMessage
    {
    public string GetMessage(string Message)
    {
    return "Your Message: " + Message;
    }

    public string PaymentDetails(ComplexObject cObject)
    {
    return " Message: " + cObject.Message + " Number: " + cObject.Number;
    }
    }
    }


    Thanks
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,445
    Rep Power
    4539
    Sorry, I have no idea if a NET C# dll can be hosted in vbscript/classic asp. Possibly not, NET didn't exist during classic asp's heyday. Try some other known to work com object in your code to verify the rest of it.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester

IMN logo majestic logo threadwatch logo seochat tools logo