Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Why can't I see classes in my C# dll ?

Solved!
Go to solution

It seems like a stupid question which will have an obvious answer but I'm stuck so....

 

I am using Visual C# express 2008 to make my dll and would like to call my methods from TestStand 2012. I have taken the default Dotnet template, added the ref to the project and kept it deliberately simple for the purpose of this test; here it is:-

 

usingSystem;

usingSystem.Collections.Generic;

usingSystem.Linq;

usingSystem.Text;

usingNationalInstruments.TestStand.Interop.API;    // TestStand Core API.  Add <TestStand>\API\DotNet\Assemblies\CurrentVersion\NationalInstruments.TestStand.Interop.API.dll to your project as a reference.

usingSystem.Runtime.InteropServices;

 

namespace

TestStand_IF

{

    

classDummyClassName

    {

       

publicvoid DummyFunctionName(SequenceContext seqContext, outString reportText, outbool errorOccurred, outint errorCode, outString errorMsg)

        {

            reportText =

String.Empty;

            errorOccurred =

false;

            errorCode = 0;

            errorMsg =

String.Empty;

           

try

            {

               

// INSERT YOUR SPECIFIC TEST CODE HERE

                reportText = "Success !";

               

// The following code shows how to access properties and variables via the TestStand API

               

// PropertyObject propertyObject = seqContext.AsPropertyObject();

               

// String lastUserName = propertyObject.GetValString("StationGlobals.TS.LastUserName", 0);

            }

           

catch(COMException e)

            {

                errorOccurred =

true;

                errorMsg = e.Message;

                errorCode = e.ErrorCode;

            }

        }

    }

}

 

I add a "String Value" step in TestStand and alsign my dll but there is nothing to select in the root class box. I remember having similar problems maybe a decade ago in C - having to mark functions for export and checking that the type library was included but I don't think this is the case here.

0 Kudos
Message 1 of 6
(7,598 Views)
Solution
Accepted by topic author Georgey48

Hi,

 

Try

 

Public DummyClassName

 

 

Curt

 

0 Kudos
Message 2 of 6
(7,581 Views)

As far as I know, you can't just call a method in a class in C#.

You need to create a new object of that class.

If you want to be able to create a method without first creating an object, you can make that method Shared.

0 Kudos
Message 3 of 6
(7,581 Views)

Thank you Curt,

 

I said It would be something obvious ;o)

0 Kudos
Message 4 of 6
(7,573 Views)

I had wondered about this myself. Why there is no constructor in the template but I guess, now that I can see the class, I can add constructor(s). I'll keep you all posted.

Thanks for your help

0 Kudos
Message 5 of 6
(7,571 Views)

All works fine, even without a constructor; don't know how but it does.

Thanks for everyones help..

0 Kudos
Message 6 of 6
(7,566 Views)