Quantcast
Channel: Questions in topic: "crash"
Viewing all articles
Browse latest Browse all 2383

unity creashes when using a pinvoke with input string

$
0
0
hi,
I'm using unity 2019.2.13f1
I have created a c++ dll that I'm using in my unity project.
I've created a method that has const char* (string) as input in the c++:

extern "C" { __declspec(dllexport) double __stdcall get_au(const char* au) { for (auto reg : *au_reg1) { if (reg.first.compare(au) == 0) return reg.second; } return -1; } } when I'm sending it from my test c# project it is working fine.
but when I'm trying to send from my unity project, the process crashes.
this is my c# declaration:

[DllImport("au_FeatureExtraction.dll", EntryPoint = "get_au", CallingConvention = CallingConvention.Cdecl)] static extern double get_au(string au); I have other functions that uses the **same DLL** with\without in parameters and it works fine for that. (example for other method that works):

c++: extern "C" { __declspec(dllexport) int __stdcall getdetection_success() { return detection_success; } } c#: [DllImport("FeatureExtraction.dll", EntryPoint = "getdetection_success", CallingConvention = CallingConvention.Cdecl)] static extern int getdetection_success();

Viewing all articles
Browse latest Browse all 2383

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>