C # dll call in vbscript

I am trying to call a C # dll from QTP (uses vbscript). I tried several things without success:

  • Visual studio 2010
  • Create C # class libary (st.dll)

code:

using System;
using System.Collections.Generic;
using System.Text;   

namespace st
{
    public class Class1
    {
        public static int GetValue()
        {
            return 34;
        }
    }
}
  • regasm /codebase st.dll
    • fail "because it is not a valid .NET assembly

In QTP / vbscript I tried

  • extern.Declare micInteger, "GetValue", "e:\st.dll", "GetValue"
    • Returns the message: "Invalid call or procedure argument"

Regardless of QTP, I would really appreciate how to call C # dll from a .vbs file.

+5
source share
3 answers

I was able to complete this work by doing the following:

Create a new C # dll in VS 2010.

namespace st4
{
    public class st4_functions
    {
        public int GetValue()
        {
            return 34;
        }
    }
}

In QTP, I added the following lines:

Set obj = DotNetFactory.CreateInstance("st4.st4_functions", "c:\\st4.dll")
MsgBox obj.GetValue()

, . COM-, , .NET . !

EDIT:

, :

http://www.solutionmaniacs.com/blog/2012/5/29/qtp-calling-c-dll-in-vbscript.html

+8

, , . , DLL COM, script , CreateObject.

.NET COM-

+1

. , .NET, , , COM-.

+1

All Articles