Page 1 of 1

[SOLVED] WebClientWithCredentials broken?

Posted: Sun Jun 30, 2019 12:13 pm
by TaterJuice
Trying to implement Rest API support, but I can't use the WebClientWithCredentials.Credentials mode. I get a design-time error, and my app won't compile:

Code: Select all

client.CredentialsMode = System.Net.CredentialsMode.Enabled;

Error CS0433 The type 'System.Net.CredentialsMode' exists in both 'CSharpXamlForHtml5.System.dll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' and 'CSharpXamlForHtml5, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'


So, I managed to work around this by creating a new CSHTML5 class library, and changing the alias of "CSharpXamlForHtml5.System.dll" from "global" to "sys", and then creating a new subclass of the WebClientWithCredentials class, which I called "WebClientWithAuth". Since I changed the alias of the System.dll, I was able to hard-code the CredentialsMode to Enabled, see the following sample:

Before Alias:
Image

After Alias:
Image

Re: WebClientWithCredentials broken?

Posted: Tue Jul 02, 2019 4:32 am
by JS-Support @Userware
Thanks a lot.

Normally the error "The type 'System.Net.CredentialsMode' exists in both..." can be ignored. It is not supposed to prevent the compilation of the application.

By the way, this is fixed in version 2.0 Preview. By any chance, have you tried to update your project to version 2.0? (please be sure to make a backup copy of the project before updating)

Re: WebClientWithCredentials broken?

Posted: Fri Jul 05, 2019 8:55 am
by TaterJuice
JS-Support @Userware wrote:Thanks a lot.

Normally the error "The type 'System.Net.CredentialsMode' exists in both..." can be ignored. It is not supposed to prevent the compilation of the application.

By the way, this is fixed in version 2.0 Preview. By any chance, have you tried to update your project to version 2.0? (please be sure to make a backup copy of the project before updating)


I did try, but didn't get very far until I encountered errors. I scrapped it because I'm on a deadline and the 2.0 release wasn't my priority. I apologize. I will try again soon, after my next release with the stable channel.

Re: WebClientWithCredentials broken?

Posted: Tue Jul 09, 2019 6:04 am
by TaterJuice
The 2.0 preview did resolve this issue.

Re: WebClientWithCredentials broken?

Posted: Fri Jul 12, 2019 3:19 am
by JS-Support @Userware
TaterJuice wrote:The 2.0 preview did resolve this issue.


Thanks