WebServices on Unity, Dll, compatibility with .Net 4.0

扶醉桌前 提交于 2020-01-05 08:42:00

问题


I'm trying to use web services on unity. I used svcutil to generate a proxy class, however the proxy class was using "System.Threading.Tasks".

I noticed that System.Threading.Tasks wasn't aviable on .Net 3.5. So I went to player setting and I changed to .Net 4.x

But now I have an other issue, and I cannot find a way to fix it, I need to use System.Web.dll and System.Web.Services.dll to make my web service work, however, the dll that are include in Program Files\Unity\Editor\Data\Mono\lib\mono\2.0 are all targets for .Net 3.5.

So that mean I cannot use them on .Net 4.x

I've been looking for quiet long and was unable to find any answer. I can add the code to the proxy class here if it's require, but I don't think it would be useful. Should I download those dll somewhere? Anyone ever seen thoses issues somewhere?


回答1:


You are using the wrong dll version.

Once you change Api Compatibility Level to Net 4.x, you have to copy the System.Web.dll and System.Web.Services.dll files from <UnityInstallationDirectory>\Editor\Data\MonoBleedingEdge\lib\mono\4.5 to your <Project>\Assets path.

That's it. Restart Visual Studio and Unity.




回答2:


There is another method of linking missing libraries as described in this unity documentation.

Create a file called csc.rsp and put these 2 lines in it:

-r:System.Web.dll
-r:System.Web.Services.dll

And yes, you better set compatibility level to .NET 4.x You also might want to restart Unity or VS in some cases.



来源:https://stackoverflow.com/questions/51084942/webservices-on-unity-dll-compatibility-with-net-4-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!