This project is read-only.

A first chance exception of type 'System.UnauthorizedAccessException' occurred in DotRas.dll

Apr 2, 2015 at 1:41 AM
I write new VPN Client with c# using DotRas but i got exception on UpdateCredentials.

Code line:
System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("testing", "123456");
Here is error message:

"A first chance exception of type 'System.UnauthorizedAccessException' occurred in DotRas.dll

Additional information: The application attempted to set default credentials for a per-user connection, or the user does not have the correct privileges to set pre-shared keys or credentials for all users."
Apr 3, 2015 at 2:57 AM
As indicated in the error message from Windows, you're telling DotRas to store the credentials for all users. If the connection is a user connection and not stored for all users it won't work. Or your application needs to have its permissions elevated to make the appropriate changes.