- Home /
Managed Plugin with System.Device assembly gives error
Hello, I wrote a plugin that references the System.Device.dll assembly. When I put the plugin into the Assets/x64 folder I get this error:
Assembly 'Assets/Plugins/x64/GpsPlugin_Net4.dll' will not be loaded due to errors:
Unable to resolve reference 'System.Device'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.
I have also added a csc.rsp file to the Assets/Editor directory and it includes the line:
-r:System.Device.dll
I've tried using both Mono and IL2CPP scripting backend. The Api Compatability Level is .NET 4.x. The System.Device namespace was introduced in .Net 4.0 so doesn't IL2CPP support .Net up to 4.6?
Is there some restriction for certain libraries such as System.Device.dll ? Trying to access the Windows GPS sensor data from Unity? Since this isn't a mobile device I can't use Input.Location.
Can you help @JoshPeterson ?
Answer by JoshPeterson · Mar 25, 2020 at 03:58 PM
Unity does not support System.Device.dll - in fact the base class libraries Unity ships with do not include it. You may be able to manually add it to your project as a managed plugin from Nuget though. See https://www.nuget.org/packages/System.Device.Location.Portable/
Thanks for the suggestion - unfortunately that Nuget package is only for manipulating GeoCoordinates and not for actually getting the lat/lon from the OS.
BTW - I have assumed that Unity's Input.Location API isn't going to work based on the fact that the documentation says its for portable devices only. Does that mean it will only work for Andoid and IOS devices? I consider my Windows Laptop a portable device so will that Input.Location API work? I have Location Services turned on in my Windows settings.
If it won't work, what exactly will be the reason, like how does it decided if I'm using a portable device or not?
I guess I'll have to try it.
I'm unsure about the Unity API's platform support in this case, sorry. It might be worth a try to see what happens though.
Your answer
Follow this Question
Related Questions
"Error Invalid option '6' for /langversion; must be ISO-1, ISO-2, 3, 4, 5 or Default" using .Net 4.6 1 Answer
No Option to Select .NET 4.x API Compatibility 1 Answer
Building Project that contains .NET dependencies with Travis CI 0 Answers
System.IO.Ports with .Net Standard 2.0? 1 Answer
Anyway to workaround .NET 4.0 framework outside/inside Unity? 1 Answer