Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event with numerics (enum/int/byte) argument triggers NullReferenceException #4

Open
M1raclee opened this issue Feb 29, 2024 · 6 comments

Comments

@M1raclee
Copy link

Description of the problem

When I try to call event with any numerics on client-side it triggers an exception:
System.NullReferenceException: Object reference not set to an instance of an object.

client-side code (main class, inherited of Resource. Also tried AsyncResource):

public enum TestEnumEvent
    {
        Test1,
        Test2,
        Test3
    }

    private event Action<TestEnumEvent> TestEvent;
    
    public override void OnStart()
    {
        Alt.Log("Starting resource...");
        TestEvent += EventCallback;
        
        TestEvent?.Invoke(TestEnumEvent.Test2);
        Alt.Log("Started ==> R");
    }
     void EventCallback(TestEnumEvent e)
    {
        Alt.Log($"##### Test event: {e}");
    }

Same problem with int:

private event Action<int> TestEvent;
    
    public override void OnStart()
    {
        Alt.Log("Starting resource...");
        TestEvent += EventCallback;
        
        TestEvent?.Invoke(123);
        Alt.Log("Started ==> R");
    }
    
    void EventCallback(int e)
    {
        Alt.Log($"##### Test event: {e}");
    }

float type just crash the client, with no extra exceptions in client logs

Null-ref triggers on this line:
TestEvent?.Invoke

If I change int/byte/enum to string or custom class - this code works fine, without exceptions

Reproduction steps

  • Create client-side C# resource
  • Create event Action with enum/int/byte param
  • Subscribe on event
  • Trigger event
  • Check console/log file to see null-exception

Expected behaviour

No exceptions for numberics types in Actions

Operating system

Windows 10

Version

Client version: 16.0.100 / 16.0.0-dev.239 / AltV.Net.Client 16.0.3
Server version: 16.0.100 / 16.0.0-dev.239 / AltV.Net 16.0.3

@Doxoh
Copy link
Collaborator

Doxoh commented Mar 4, 2024

image
works for me @M1raclee

also for int and byte. Cannot repo it.

Tryed with Nuget 16.0.0-dev.30

@M1raclee
Copy link
Author

M1raclee commented Mar 4, 2024

I have the same problem with 16.0.0-dev.30 NuGet.
Did you test in on client-side @Doxoh ?
Because your screenshot looks like server-side console

image

@Doxoh
Copy link
Collaborator

Doxoh commented Mar 4, 2024

whats ur line 44?

@M1raclee
Copy link
Author

M1raclee commented Mar 4, 2024

image

@Doxoh
Copy link
Collaborator

Doxoh commented Mar 4, 2024

i will check more

@Doxoh
Copy link
Collaborator

Doxoh commented Mar 17, 2024

an update for u, i found the reason for the problem, now i need to find a way to fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants