-8

I have created a COM dll written in C#. It is registered successfully and I am trying to access it in VB script. I am able to create the object of the COM and am able to execute first method call.

When I try to execute the second method call (msg = app.getSubDomainConn( domain)), with the object returned by first method call, I get following error. I have posted both VBscript and C# code.

Could someone please help?

Error: Invalid procedure call or argument: 'getValidConnectionMsg'
Code: 800A0005
Source: Microsoft VBScript runtime error

dim app 
Set app  = CreateObject("myCOM.myObject.")

app.uri=<URI>
app.username=<User>
app.password=<pwd>

Dim domain
Set domain = app.getDomain()
domain.ok = true;

wscript.echo domain.name

dim msg 
msg = app.getSubDomainConn(domain)

Here is C# code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace myCOM
{

    
    public class myObject
    {
        public String uri = "";
        public String username = "";
        public String password = "";

        public IDomain getDomain()
        {
            String msg = "";
             IDomain domain = null;
            try
            {

               
                // Get domain Connection
                IConnection conn = Factory.Connection.GetConnection(uri);
                UserCredentials creds = new UsernameCredentials(username, password);

                // Get domain.
                domain = Factory.Domain.Get(conn);
                

            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.ToString());
            }
            return domain;
        }



        public String getValidConnectionMsg(IDomain domain)
        {
            String isDomainAvailable = "Not Available";
            if (domain != null)
            {
                isDomainAvailable = domain.Name; 

            }

            return isDomainAvailable;

        }

    }

}
4
  • 2
    You have been asked under the previous incarnation of this question: "Is getValidConnectionMsg in your code somewhere?" Commented Jan 15, 2022 at 15:05
  • Yes getValidConnectionMsg is part of my C# code. I have given that code in my post. Commented Jan 15, 2022 at 15:12
  • The error is coming from VBScript. You are not calling getValidConnectionMsg from VBScript, so you cannot be getting that error. Instead you are calling getSubDomainConn from VBScript, which is not even present as a method in myObject. Which is why you were asked, Is getValidConnectionMsg in your code somewhere. Commented Jan 15, 2022 at 15:24
  • 3
    Why did you delete the previous question instead of just editing it? Deleting a question means any comments are lost. Commented Jan 15, 2022 at 17:02

1 Answer 1

0

The problem was that VB script variant datatype only considers object. I had to make a change in C# code. Instead of accepting it as a IDomain object, It should have been an Object type argument. Instead of below

 public String getValidConnectionMsg(IDomain domain)
        

Modified code is

public String getValidConnectionMsg(Object d)
{
IDomain domain = (IDomain)d;
.
.
.
Sign up to request clarification or add additional context in comments.

1 Comment

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.