c# - NullReferenceException in SharpSvn's SvnClient when the supplied DefaultCredentials returns null -


i'm using sharpsvn in project communicate svn. svn repostories, know user name , password, while others, don't. thus, set svnclient.authentication.defaultcredentials property instance of own implementation of system.net.icredentials (pseudo code):

public class mycredentials : icredentials {     public networkcredential getcredential(uri uri, string authtype)     {         if (arecredentialsknown(uri))             return new networkcredential("knownusername", "knownpassword");         else             return null;     } } 

this works fine known credentials. however, if credentials not known, nullreferenceexception occurs in sharpsvn:

object reference not set instance of object.    @ system.net.networkcredential.internalgetusername()    @ system.net.networkcredential.get_username()    @ sharpsvn.implementation.svncredentialwrapper.onusernamepassword(object sender, svnusernamepasswordeventargs e) in f:\qqn\sharpsvn-dist-1.6\src\sharpsvn\svnauthentication.h:line 619 

this apparently caused fact return null getcredential method. however, stated the msdn documentation on icredentials interface:

the getcredential method returns networkcredential instance contains credentials associated specified uri , authorization scheme. when no credentials available, getcredential method returns null.

is bug in sharpsvn? otherwise, supposed return when credentials not known?

edit: discovered can return new networkcredentials() instead of null indicate sharpsvn credentials unknown. still, think bug in sharpsvn returning null should work equally well.

the .defaultcredentials alternative providing 1 explicit username , password subversion libraries.

if need more advanced prompting mechanism should hook .usernamepassword event on svnclient.autorization. allows managing if passwords should saved, etc.

there default implementation in sharpsvn.ui.dll hooks standard dialogs.


Comments