Search code examples
c#.netpoint-of-saleopos

CAS policy on .NET 4.5 with Microsoft.PointOfService


I am working on a Point Of Sale (POS) app on Visual Studio 2017 enterprise edition. The target framework is .NET framework 4.5, I have installed Microsoft POS for .NET 1.12 (OPOS) and I was able to get the MSR card reader with:

PosExplorer myPosExplorer = new PosExplorer();

So far it was running great until today in the morning after installing True Key Intel, my POS started to crash when getting the MSR reader with this error:

the type initializer for microsoft.pointofservice.management.explorer threw an exception.

System.notsupportedexception: this method explicitly uses CAS policy, which has been obsoleted by the .NET framework. In order to enable cas policy for compatibility reasons, please use the newfx40_legacysecuritypolicy configuration switch. please see http://go.microsoft.com/fwlink/?LinkID=155570 for mor information. at system.securitymanager.resolvepolicy(evidence evedence) at microsoft.pointofservice.management.explorer.scanforsoassemblies()

I had never faced this error before, so i started to search on the web and i found this page. It basically says OPOS is not supported for .NET 4.0 (Which i am not using!!!)

I am using Git, so i rolled back to a previous version of the code and have no luck. I run the POS on a new Windows with a new Visual Studio and the problem stills there.

What is it wrong with OPOS? Am i missing some registry configuration? Why does this keep telling me about CAS policy when it was dropped on .NET 4.0 and I am using .NET 4.5? Is there any other better way to control peripherals like MSR readers, printers, line displays, etc. ?


Solution

  • If you can, I would suggest that you update to POS for .NET 1.14.1 and update your service objects.

    That said, since you're using .NET 4.5, you're in the same boat as the article you linked regarding .NET 4.0

    You should be able to add the legacy CAS switch in your app.config file for it to work. Just ensure the following block of code is in your app.config. Note that there is probably already a configuration element in the config file, so you should only need to add the runtime section.

    <configuration>
       <runtime>
          <NetFx40_LegacySecurityPolicy enabled="true"/>
       </runtime>
    </configuration>