Using .NET Framework Functions Within .NET

For best results using .NET test code with Silk Performer, call BDL functions from within .NET code. The .NET assembly perfdotnetfw.dll that comes with Silk Performer implements the Silk Performer.Bdl class, where most BDL functions are implemented.
  1. Add a reference to perfdotnetfw.dll in your .NET project. This DLL can be found in the Silk Performer installation directory.
  2. Import the Silk Performer namespace (see the necessary code below, depending on your implementation language).
    using Silk Performer; // C#
    imports Silk Performer // VB.NET
     
  3. Use the static functions in your .NET Code.

    For example:

    Bdl.Print("This is a message from within a .NET Assembly");
    
    The functions that are defined by the BDL class can only be used if the .NET assembly runs in a virtual user. This is because perfrun.exe functions (virtual user process) will be called.

    Sample Bdf Script

    dcltrans
      transaction TMain
      var
    hObject, hObject2 : number;
    hReturn : number;
      begin
        DotNetSetString(hObject, "ConstrValue1");
        hObject := DotNetLoadObject("bin\\Release\\TestDriver.dll", "TestDriver.TestClass");
        hObject2 := DotNetLoadObject("bin\\Release\\TestDriver.dll", "TestDriver.ParamClass");
        DotNetSetFloat(hObject, 1.23);
        DotNetSetInt(hObject, 123);
        DotNetCallMethod(hObject,"TestMethod");
        DotNetGetObject(hObject, hReturnValue);
        DotNetFreeObject(hObject);
        DotNetFreeObject(hObject2);
        DotNetFreeObject(hReturn);
      end TMain;

    Sample .NET Code (C#)

    using System;
    using Silk Performer;
    namespace TestDriver
    {
      public class TestClass
    {
    
    public TestClass(string sConstrValue)
    {
    Bdl.Print("Constructor called with param" + sConstrValue);
    }
    
    public TestClass()
    {
    Bdl.Print("Default Constructor called!");
    }
    
    public ParamClass TestMethod(double fParam, int nParam)
    {
    return new ParamClass(fParam, nParam);
    }
    }
    
      public class ParamClass
    {
    public double mfMember;
    public int mnMember;
    
    public ParamClass(double fParam, int nParam)
    {
    mfMember = fParam;
    mnMember = nParam;
    }
    
    public ParamClass()
    {
    mfMember = 0.0;
    mnMember = 0;
    }
    }
    }