WebClientWithCredentials broken?

Please post public support tickets here. Note: for private support tickets, please send an email to support@cshtml5.com instead.
TaterJuice
Posts: 133
Joined: Thu Mar 16, 2017 5:40 am
Contact:

WebClientWithCredentials broken?

Postby TaterJuice » Sun Jun 30, 2019 12:13 pm

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

JS-Support @Userware
Site Admin
Posts: 1050
Joined: Tue Apr 08, 2014 3:42 pm

Re: WebClientWithCredentials broken?

Postby JS-Support @Userware » Tue Jul 02, 2019 4:32 am

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)

TaterJuice
Posts: 133
Joined: Thu Mar 16, 2017 5:40 am
Contact:

Re: WebClientWithCredentials broken?

Postby TaterJuice » Fri Jul 05, 2019 8:55 am

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.

TaterJuice
Posts: 133
Joined: Thu Mar 16, 2017 5:40 am
Contact:

Re: WebClientWithCredentials broken?

Postby TaterJuice » Tue Jul 09, 2019 6:04 am

The 2.0 preview did resolve this issue.

JS-Support @Userware
Site Admin
Posts: 1050
Joined: Tue Apr 08, 2014 3:42 pm

Re: WebClientWithCredentials broken?

Postby JS-Support @Userware » Fri Jul 12, 2019 3:19 am

TaterJuice wrote:The 2.0 preview did resolve this issue.


Thanks


Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 1 guest

 

 

cron