Using System.Device in an MVC Project

This makes no sense.

I am trying to use the System.Device library in a project to take advantage of the geolocation features. I am adding code to the Razor page, as usual.

I have a link to the library, and I added use at the top of the razor:

@using System.Device; 

The device has a red underline because it cannot be found. Entering System.D does not give Device in intellisense. This does not seem to make sense since the library is definitely referencing.

There are no links to System.Device in the Web.config file. If I do a full search for a solution for a β€œdevice,” there is no mention of it anywhere that I would not expect.

I have open and closed files, deleted links, reboot VS, reboot my computer. Everything. It is still preserved.

I feel either there that I do not know, or I am doing something stupid. Did I miss something?

+1
source share
1 answer

There are no links to System.Device in the Web.config file.

You need to add System.Device to your web.config. Depending on whether you use areas, you may need to add it to web.config for that area. If it is not in web.config, the razor does not know about it.

  <namespaces> <add namespace="System.Device" /> </namespaces> 

Also, try setting Copy Local to True for the reference properties of System.Device. This did not work for me until I did both.

+1
source

Source: https://habr.com/ru/post/1014274/


All Articles