Demonik
Demonik
CC#
Created by Demonik on 4/15/2024 in #help
Crossplatform VarArg PInvoke
What's the current correct way to declare PInvoke C library function with vararg parameters that works on at least Mac, Windows, Android and Linux? I know the actual maximum number of parameters so I don't care if I have to write multiple functions, what I'm interested in is if it will work correctly on all platforms.
25 replies
CC#
Created by Demonik on 4/12/2024 in #help
RestSharp multipart request in from Unity fails with NRE after successfully sending request
With this stack trace:
NullReferenceException: Object reference not set to an instance of an object
System.Net.Http.MultipartContent.Dispose (System.Boolean disposing) (at <92a43029e91441ee9df5714eb5dcd209>:0)
System.Net.Http.HttpContent.Dispose () (at <92a43029e91441ee9df5714eb5dcd209>:0)
RestSharp.RequestContent.Dispose () (at <dfd03b4ab8614e549933c37db1618c06>:0)
RestSharp.RestClient.ExecuteRequestAsync (RestSharp.RestRequest request, System.Threading.CancellationToken cancellationToken) (at <dfd03b4ab8614e549933c37db1618c06>:0)
RestSharp.RestClient.ExecuteAsync (RestSharp.RestRequest request, System.Threading.CancellationToken cancellationToken) (at <dfd03b4ab8614e549933c37db1618c06>:0)
TestComponent.TestWebhookSend () (at Assets/Runtime/Scripts/TestComponent.cs:106)
NullReferenceException: Object reference not set to an instance of an object
System.Net.Http.MultipartContent.Dispose (System.Boolean disposing) (at <92a43029e91441ee9df5714eb5dcd209>:0)
System.Net.Http.HttpContent.Dispose () (at <92a43029e91441ee9df5714eb5dcd209>:0)
RestSharp.RequestContent.Dispose () (at <dfd03b4ab8614e549933c37db1618c06>:0)
RestSharp.RestClient.ExecuteRequestAsync (RestSharp.RestRequest request, System.Threading.CancellationToken cancellationToken) (at <dfd03b4ab8614e549933c37db1618c06>:0)
RestSharp.RestClient.ExecuteAsync (RestSharp.RestRequest request, System.Threading.CancellationToken cancellationToken) (at <dfd03b4ab8614e549933c37db1618c06>:0)
TestComponent.TestWebhookSend () (at Assets/Runtime/Scripts/TestComponent.cs:106)
This is what I'm doing:
request.Method = Method.Post;
request.AddFile("file1", file.FullName);
request.AddParameter("payload_json", message.ToJsonString(), ParameterType.RequestBody);
var response = await client.ExecuteAsync(request);
request.Method = Method.Post;
request.AddFile("file1", file.FullName);
request.AddParameter("payload_json", message.ToJsonString(), ParameterType.RequestBody);
var response = await client.ExecuteAsync(request);
It actually successfully sends request but immediately throws exception inside. Without attachment it works fine. Am I doing something wrong or is this a bug?
6 replies