Page 1 of 1

[SOLVED] WebClient exception | Windows 10 spring 2018 update

Posted: Wed May 02, 2018 5:30 am
by TobiasDonaubauer
Since the current Windows 10 spring 2018 update, this code:

Code: Select all

  var webClient = new WebClient();
  webClient.Encoding = Encoding.UTF8;
  webClient.Headers[HttpRequestHeader.Accept] = "application/json";


throws an exception when running in the browser:

Uncaught Error: Type 'System.Text.UTF8Encoding+UTF8EncodingSealed' has not been defined.
at Object.JSIL.RuntimeError (JSIL.Core.js:10531)
at Object.JSIL.GetTypeByName (JSIL.Core.js:1100)
at JSIL.TypeRef.getNoInitialize (JSIL.Core.js:1818)
at InitFieldDefault (JSIL.Core.js:6910)
at PreInitField_Cleanup (JSIL.Core.js:677)
at JSIL.PreInitMembrane.cleanup (JSIL.Core.js:652)
at JSIL.PreInitMembrane.bound_cleanup [as cleanup] (JSIL.Core.js:595)
at JSIL.PreInitMembrane.maybeInit (JSIL.Core.js:616)
at JSIL.PreInitMembrane.bound_maybeInit [as maybeInit] (JSIL.Core.js:592)
at Object.JSIL.InitializeType (JSIL.Core.js:4528)


I am currently using Visual Studio 2017. Before the update everything worked fine!

I tried it in Chrome and Edge. Both run into the same exception.

Re: WebClient exception | Windows 10 spring 2018 update

Posted: Thu May 03, 2018 8:15 am
by joaofig
Same here. Any known workaround? We are using the WebClient class to access our REST APIs.

Re: WebClient exception | Windows 10 spring 2018 update

Posted: Fri May 04, 2018 6:03 am
by JS-Support @Userware
Hi,

Thanks for reporting this issue.

Can you please try the REST demo in the sample showcase app?

To do so, in VS, click "File -> New Project -> CS/XAML for HTML5 -> Sample Showcase", then run it, click "WCF", and try out the REST demo.

Thanks,
Regards,
JS-Support

Re: WebClient exception | Windows 10 spring 2018 update

Posted: Fri May 04, 2018 9:31 am
by TobiasDonaubauer
Same issue. See image

issue.png
issue.png (135.24 KiB) Viewed 17002 times

Re: WebClient exception | Windows 10 spring 2018 update

Posted: Fri May 04, 2018 9:59 am
by JS-Support @Userware
Thanks! We are going to fix it asap.

Re: WebClient exception | Windows 10 spring 2018 update

Posted: Mon May 07, 2018 7:07 am
by JS-Support @Userware
Hi,

We haven't had the chance to try out the Spring update yet, but we may have found a solution.

Can you please try to apply the following hotfix and let me know if it fixes the issue?

Here is the hotfix:

1. Download the following ZIP file:
CSHTML5 v1.1.2 hotfix1.zip
(77.15 KiB) Downloaded 612 times


2. Extract it on your disk

3. Copy the file "CSharpXamlForHtml5.Compiler.dll" from the extracted file into the following folder:
C:\Program Files (x86)\MSBuild\CSharpXamlForHtml5\InternalStuff\Compiler

Make sure to replace the existing file. If there is no file to replace, you are probably copying it to the wrong location.

4. Rebuild your project.


Thank you.
Regards,
JS-Support

Re: WebClient exception | Windows 10 spring 2018 update

Posted: Mon May 07, 2018 7:55 pm
by TobiasDonaubauer
It fixed the issue! Thanks a lot for your support.

Re: WebClient exception | Windows 10 spring 2018 update

Posted: Wed May 09, 2018 6:00 am
by JS-Support @Userware
TobiasDonaubauer wrote:It fixed the issue! Thanks a lot for your support.


Thanks!

Re: WebClient exception | Windows 10 spring 2018 update

Posted: Tue Jul 10, 2018 7:33 am
by JS-Support @Userware
The fix is now part of v1.2 beta 1 and newer, available at:
http://forums.cshtml5.com/viewforum.php?f=6