I think you can use the Web8 In Process Dlls from "SDL Web 8.1.1 release\Content Delivery\roles\api\in-process\dotNet\bin" inside your web application to continue using this piece of code.
Indeed when using a standalone Context microservice, the devices database is part of the service, so you do not need it inside your webapp anymore, it is the main goal of ...
Your stacktrace contains the magic (and dirty ;o) word JuggerNET, which I think indicates you are still refering to DLLs that are pre Web 8.
So you seem to be trying to run something which is using both versions, or is not completely migrated to Web 8.
Perhaps is possible to try and detect the cookie in your app code, if it's not found, send the user to a page where this value is set ("proxy page"). Once set, then you can redirect to the relevant URL?
Your proxy page can be really lightweight so you're not making major http requests etc, just a quick set of content, then move on.
It looks like the ADF is using default values for the displayWidth and displayHeight claims, which means either:
Your device database is not up to date (or been created)
I would check that your browsers are not blocking JS or cookies, and that there are no ...