2017-05-31 106 views
0

我正在開發銷售點(POS)應用程序在Visual Studio 2017企業版上。目標框架是.NET框架4.5,我已經安裝了Microsoft POS用於.NET 1.12(OPOS),我能夠用得到的MSR讀卡器:.NET 4.5上的CAS策略與Microsoft.PointOfService

PosExplorer myPosExplorer = new PosExplorer();

到目前爲止,它是在直到今天運行的大早上安裝True Key Intel後,我開始了POS與此錯誤獲取MSR讀卡器時崩潰:

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()

我從來沒有遇到這個錯誤之前,所以我就開始在網絡上搜索,我發現這個page。它基本上說OPOS不支持.NET 4.0(我不使用!!!)

我使用Git,所以我回滾到以前版本的代碼,並沒有運氣。我使用新的Visual Studio在新的Windows上運行POS,問題仍然存在。

OPOS有什麼問題?我是否缺少一些註冊表配置? 爲什麼這會一直告訴我關於CAS策略,當它放在.NET 4.0上並且我正在使用.NET 4.5時? 有沒有其他更好的方法來控制MSR閱讀器,打印機,線路顯示器等外設?

回答

1

如果可以,我建議您更新到.NET 1.14.1的POS並更新您的服務對象。

這就是說,因爲你正在使用.NET 4.5,你在同一條船上的文章您鏈接關於.NET 4.0

你應該能夠在add the legacy CAS switch爲它的app.config文件上班。請確保以下代碼塊位於您的app.config中。請注意,配置文件中可能已有configuration元素,因此您只需要添加runtime部分即可。

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