# Avoid instance method invocation if there is no instance

**URL:** <http://forum.vvvv.org/t/avoid-instance-method-invocation-if-there-is-no-instance/24950>\
**Category:** feature\
**Created:** [January 14, 2026, 11:35am UTC](http://forum.vvvv.org/t/avoid-instance-method-invocation-if-there-is-no-instance/24950 "2026-01-14T11:35:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![antokhio](http://forum.vvvv.org/user_avatar/forum.vvvv.org/antokhio/32/39_2.png) [@antokhio](http://forum.vvvv.org/u/antokhio)\
**Post date:** [January 14, 2026, 11:35am UTC](http://forum.vvvv.org/t/avoid-instance-method-invocation-if-there-is-no-instance/24950/1 "2026-01-14T11:35:15Z")

</div>

Hi, digging on NURBS library, and noticed something that seems to need some polishing on vl side.

So I have a C# struct, that manages native memory:

```auto
public record struct NurbsCurve
{
        // some properties
   
        // instance method
        public float GetParamByLength(float length)
        {
            return (float)
                LNLibNurbsCurve.GetParamByLength(
                    NativeCurve,
                    length,
                    IntegratorType.INTEGRATOR_GAUSS_LEGENDRE
                );
        }
}

```

So, when I add this method from node browser, I get an instant crash, since it tries to use unassigned native memory… Normally you get just an exception that instance was null but in this case vvvv is gone… I’m adding some safety checks obviously. However if I define Class in vl, and try to add method to patch witch is disconnected from instance I don’t have error.

The question is:

Can this be resolved on VL side of things, or maybe C# declaration can be decorated with something?

---

<div class="post-metadata">

**Author:** ![tonfilm](http://forum.vvvv.org/user_avatar/forum.vvvv.org/tonfilm/32/406_2.png) [@tonfilm](http://forum.vvvv.org/u/tonfilm)\
**Post date:** [January 14, 2026, 11:59am UTC](http://forum.vvvv.org/t/avoid-instance-method-invocation-if-there-is-no-instance/24950/2 "2026-01-14T11:59:16Z")

</div>

For classes, you get a null exception, but this is a record, so the memory will always be created. In this case, struct might not be the right data type, as you probably want to pass around a reference to the curve and not copy around the memory all the time.

---

<div class="post-metadata">

**Author:** ![antokhio](http://forum.vvvv.org/user_avatar/forum.vvvv.org/antokhio/32/39_2.png) [@antokhio](http://forum.vvvv.org/u/antokhio)\
**Post date:** [January 14, 2026, 12:54pm UTC](http://forum.vvvv.org/t/avoid-instance-method-invocation-if-there-is-no-instance/24950/3 "2026-01-14T12:54:05Z")

</div>

Well I made it this way, so you can cleanly see, when it’s changed by something. But class vs struct seems to be out of scope of this particular request, if u want to joint efforts, be my guest at [GitHub - antokhio/VL.LNLib: A NURBS, Bezier library for vvvv based on LNLib by BIMCoderLiang](https://github.com/antokhio/VL.LNLib)

I would gladly appreciate some guidance and advices, since this thing is quite complex and I’m not that much in to NURBS topic.

Basically for nurbs curve I’m about to 2-3% of whole [API](https://github.com/antokhio/VL.LNLib/blob/develop/DOCUMENTATION.md)

---

<div class="post-metadata">

**Author:** ![gregsn](http://forum.vvvv.org/user_avatar/forum.vvvv.org/gregsn/32/6_2.png) [@gregsn](http://forum.vvvv.org/u/gregsn)\
**Post date:** [January 14, 2026, 10:11pm UTC](http://forum.vvvv.org/t/avoid-instance-method-invocation-if-there-is-no-instance/24950/4 "2026-01-14T22:11:26Z")

</div>

Maybe give a class-based record a try. This way you should be able to combine the immutability feature with the reference feature.

---

<div class="post-metadata">

**Author:** ![antokhio](http://forum.vvvv.org/user_avatar/forum.vvvv.org/antokhio/32/39_2.png) [@antokhio](http://forum.vvvv.org/u/antokhio)\
**Post date:** [January 15, 2026, 1:33pm UTC](http://forum.vvvv.org/t/avoid-instance-method-invocation-if-there-is-no-instance/24950/5 "2026-01-15T13:33:31Z")

</div>

ROFL, it seem issue I was bumping was just a peak of iceberg, it seems the actual problem I have is that underlying lib throws access violations even if it’s fed with correct parameters, making the whole thing kind of unstable…

Guess I will have to abandon current state and take route to port that thing from scratch, the performance vise when you start to feed it with realtime parameters seems to be also quite slow…
