Note that there are some explanatory texts on larger screens.

plurals
  1. PONullReferenceException in SharpSvn's SvnClient when the supplied DefaultCredentials returns null
    primarykey
    data
    text
    <p>I'm using SharpSvn in my project to communicate with SVN. For some SVN repostories, I already know the user name and password, while for others, I don't. Thus, I set the <code>SvnClient.Authentication.DefaultCredentials</code> property to an instance of my own implementation of <code>System.Net.ICredentials</code> (pseudo code):</p> <pre><code>public class MyCredentials : ICredentials { public NetworkCredential GetCredential(Uri uri, string authType) { if (AreCredentialsKnown(uri)) return new NetworkCredential("KnownUserName", "KnownPassword"); else return null; } } </code></pre> <p>This works fine for known credentials. However, if the credentials are not known, a <code>NullReferenceException</code> occurs in SharpSvn:</p> <pre><code>Object reference not set to an instance of an object. at System.Net.NetworkCredential.InternalGetUserName() at System.Net.NetworkCredential.get_UserName() at SharpSvn.Implementation.SvnCredentialWrapper.OnUserNamePassword(Object sender, SvnUserNamePasswordEventArgs e) in f:\qqn\sharpsvn-dist-1.6\src\sharpsvn\svnauthentication.h:line 619 </code></pre> <p>This is apparently caused by the fact that I return <code>null</code> from the GetCredential method. However, as is clearly stated by <a href="http://msdn.microsoft.com/en-us/library/system.net.icredentials.aspx" rel="nofollow">the MSDN documentation on the ICredentials interface</a>:</p> <blockquote> <p>The <strong>GetCredential</strong> method returns a NetworkCredential instance that contains the credentials that are associated with the specified URI and authorization scheme. When no credentials are available, the <strong>GetCredential</strong> method returns <strong>null</strong>.</p> </blockquote> <p>Is this a bug in SharpSvn? Otherwise, what am I supposed to return when the credentials are not known?</p> <p><strong>Edit:</strong> I just discovered that I can return <code>new NetworkCredentials()</code> instead of <code>null</code> to indicate to SharpSvn that the credentials are unknown. Still, I think this is a bug in SharpSvn as returning <code>null</code> should work equally well.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload