How to impliement custom DLL with interop #500
Description
I don't know if this question is out of scope or not for this repo. But it's very useful to be able to add a bit of native code and invoke it from .NET. I think GHI did a great job with their OSHW library and I'm trying to use that as a template for myself.
I've added GHI's OSHW library from the community edition of v4.3 to my v4.4 code base. My .NET code runs fine, but there's something wrong with calling my native code via interop. Unfortunately whenever I call my DLL's methods with interop signatures I get...
Exception System.NotSupportedException - CLR_E_NOT_SUPPORTED (1)
What I have done is...
- Copied in the DeviceCode\GHI files.
- Modified TinyCLR.proj to include GHI's files (based on the v4.3 TinyCLR.proj)
- Built the DeviceCode\GHI\Libraries\GHI.OSHW.Hardware\Managed project using v4.4
- Copied the resulting stubs into DeviceCode\GHI\Libraries\GHI.OSHW.Hardware\Native
- The generated cpp file for my custom class is basically empty, I only added "hr = S_OK;" just to test the functionality.
- Run msbuild on the folder in step 4.
- Rebuilt TinyCLR and deployed that to device.
- Added reference to the generated GHI.OSHW.Hardware.dll in a new test project.
- Deployed and executed my test project on my device which attempts to call a method of a custom class in the DLL I've made.
Even trying to just call GHI's methods with interop signatures results in the same error. I figure I'm missing some configuration step. If anyone else has ran into this problem I'm hoping they can save me the time of tracking down the issue. Otherwise I'll post back here once I've found it myself.