WebServices on Unity, Dll, compatibility with .Net

2019-08-02 08:41发布

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条回答
干净又极端
2楼-- · 2019-08-02 09:42

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.

查看更多
登录 后发表回答