ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW 2026 .NET 8 Interop – Interface Types Replaced with LVBaseRefnum in Generated Assembly (Was Working in 2020)

 

Environment

  • LabVIEW 2020 (working scenario)

  • LabVIEW 2026 (issue)

  • .NET Framework 4.7 (old)

  • .NET 8 (new)

  • Visual Studio 2022


Background

In LabVIEW 2020, I was able to:

  1. Reference a .NET Framework 4.7 DLL

  2. Use custom interface types (e.g., ICalculator, IProbeAdjusterView) as VI inputs

  3. Build a .NET Interop Assembly from LabVIEW

  4. The generated assembly preserved the same .NET types

Example (LabVIEW 2020 generated method):

public static void Calculations(DataTransferObjects dto, ICalculator calculator)

This worked perfectly — I could pass actual C# objects from my application.


Current Scenario (LabVIEW 2026 + .NET 😎

I upgraded the same concept to .NET 8.

Steps:

  1. Created a .NET 8 class library with:

    • DTO class (DataTransferObjects)

    • Interface (ICalculator)

  2. Referenced this DLL in LabVIEW 2026

  3. Created a VI using these types as inputs

  4. Built a .NET Interop Assembly


Problem

The generated method signature is now:

public static void Calculations(
    NationalInstruments.LabVIEW.Refnums.LVBaseRefnum dto,
    NationalInstruments.LabVIEW.Refnums.LVBaseRefnum calculator)

👉 All custom .NET types are replaced with LVBaseRefnum


Impact

  • I cannot pass my C# objects anymore:

Multiply.Calculations(dto, calculator); // ❌ compile error
  • LabVIEW expects LVBaseRefnum, but:

    • These cannot be created in C#

    • They are LabVIEW-owned references


Attempted Workaround

I tried a dictionary-based mapping approach:

ConcurrentDictionary<LVBaseRefnum, object>

But:

  • I cannot obtain valid LVBaseRefnum instances from C#

  • Mapping cannot be established reliably


Runtime Issue

When trying to invoke the LabVIEW method, I get:

👉 LabVIEW Error 1776

This seems related to:

  • Type mismatch

  • Invalid refnum

  • or .NET 8 interop limitations


Working Minimal Example

C# (.NET 😎

public interface ICalculator
{
    double Multiply(double a, double b);
}

public class Calculator : ICalculator
{
    public double Multiply(double a, double b) => a * b;
}

public class DataTransferObjects
{
    public double X { get; set; }
    public double Y { get; set; }
}

LabVIEW Generated Signature (2026)

public static void Calculations(LVBaseRefnum dto, LVBaseRefnum calculator)

Key Questions

  1. Is this behavior expected in LabVIEW 2026 with .NET 8?

  2. Is there any way to:

    • Preserve original .NET types (like in LabVIEW 2020)?

  3. Can LabVIEW generate interop assemblies that expose .NET 8 interface types?

  4. How are we supposed to pass complex objects (interfaces/DTOs) across this boundary now?

  5. Is LVBaseRefnum the only supported mechanism in .NET 8 interop?

  6. If so, how can we correctly obtain and manage LVBaseRefnum from C#?


Additional Observation

Simple types (e.g., double, string) work fine.

Example:

public static double Multiply(double a, double b)

👉 Works without issues.


Expectation

Looking for:

  • Recommended architecture for LabVIEW 2026 + .NET 8 interop

  • Best practice to replace interface-based design used in .NET Framework

  • Clarification if this is a limitation or a configuration issue


Any guidance or working examples would be highly appreciated.

Thanks in advance!

0 Kudos
Message 1 of 1
(169 Views)