vb.net - Implement IReportServerCredentials error -
i took sample code implement ireportservercredentials send login information retrieve report remotely reason implementation error prone.
imports system.net imports microsoft.reporting.webforms imports system.security.principal <serializable()> _ public notinheritable class reportservernetworkcredentials implements ireportservercredentials #region "ireportservercredentials members" ''' <summary> ''' specifies user impersonate when connecting report server. ''' </summary> ''' <value></value> ''' <returns>a windowsidentity object representing user impersonate.</returns> public readonly property impersonationuser() windowsidentity implements ireportservercredentials.impersonationuser return nothing end end property ''' <summary> ''' returns network credentials used authentication report server. ''' </summary> ''' <value></value> ''' <returns>a networkcredentials object.</returns> public readonly property networkcredentials() system.net.icredentials implements ireportservercredentials.networkcredentials dim username string = _ configurationmanager.appsettings("myreportvieweruser") if (string.isnullorempty(username)) throw new exception("missing user name web.config file") end if dim password string = _ configurationmanager.appsettings("myreportviewerpassword") if (string.isnullorempty(password)) throw new exception("missing password web.config file") end if dim domain string = _ configurationmanager.appsettings("myreportviewerdomain") if (string.isnullorempty(domain)) throw new exception("missing domain web.config file") end if return new system.net.networkcredential(username, password, domain) end end property ''' <summary> ''' provides forms authentication used connect report server. ''' </summary> ''' <param name="authcookie">a report server authentication cookie.</param> ''' <param name="username">the name of user.</param> ''' <param name="password">the password of user.</param> ''' <param name="authority">the authority use when authenticating user, such microsoft windows domain.</param> ''' <returns></returns> public function getformscredentials(byval authcookie system.net.cookie, byval username string, byval password string, byval authority string) boolean implements ireportservercredentials.getformscredentials authcookie = nothing username = nothing password = nothing authority = nothing return false end function
#end region
end class
on class declaration there error line
implements ireportservercredentials
and says class must implement function getformscredentials....for interface microsoft.reporting.webforms.ireportservercredentials...
now when change function accordingly still gives same error.
i assuming full error message:
'public function getformscredentials(authcookie system.net.cookie, username string, password string, authority string) boolean' , 'public function getformscredentials(byref authcookie system.net.cookie, byref username string, byref password string, byref authority string) boolean' cannot overload each other because differ parameters declared 'byref' or 'byval'.
in syntax section of msdn docs ireportservercredentials.getformscredentials see sample code declaration.
'declaration function getformscredentials ( _ <outattribute> byref authcookie cookie, _ <outattribute> byref username string, _ <outattribute> byref password string, _ <outattribute> byref authority string _ ) boolean
your funciton declaration missing byref keyword , outattribute on each parameter. byref attribute tells vb.net compiler pass parameter's value out caller. outattribute tells compiler building calling code not need initialize parameter before passing in. can find more information out parameters directional attributes article on msdn helpful response lasse v. karlsen on stackoverflow question <out()> attribute.
the outattribute declared in system.runtime.interopservices namespace, need import statement @ top of file.
imports system.runtime.interopservices
your function should more this:
public function getformscredentials(<outattribute()> byref authcookie system.net.cookie, <outattribute()> byref username string, <outattribute()> byref password string, <outattribute()> byref authority string) boolean implements ireportservercredentials.getformscredentials authcookie = nothing username = nothing password = nothing authority = nothing return false end function
Comments
Post a Comment