Using Windows system dlls on Hololens 2 when compiled with IL2CPP

Hello,

I’m building an App which requires the use of the MAC Address of the Hololens 2 (I’m not uploading the App to the Windows Store so no worries about security here). To do so I’ve used the iphlpapi.dll. To test that this worked at all, I created a stand alone UWP App and deployed it to the Hololens. This worked perfectly well and there were no issues. I didn’t need to specify the location of the dll etc, the import simply worked.

The code sample I used was from here:

https://stackoverflow.com/questions/34097870/c-sharp-get-mac-address-in-universal-apps/34098615

I built this code into my Unity App, compiled it and then deployed it to the Hololens. It didn’t work of course. I tried hard coding the full dll path in the import in the generated C++ but not luck.

Is there something I need to do, to allow the code to access the DLL?

Any tips or help would be much appreciated. The exact error I can get tomorrow, I’m currently not in the office.

Many thanks in advance,
Peter

The Dll needs to be present (Intel Architecture) in the project. However, you need to use this DllImport:

[DllImport("__Internal", CharSet = CharSet.Ansi, ExactSpelling = true)]

This allows the dll to be statically linked. Hope this helps someone as it’s been a real pain for me.