Hi Dhananjay,
you can try with Lutz Rioeder's Reflector. Download this tool, compile your
code to produce a DLL, load it into Reflector then export it with VB...
Philippe
HI Philippe,
Thanks a lot for reply.
Here in i am providing my both code files , can you please see where
is the problem. I have tried to correct it but it was not
successful.can you please provide me correct complete code. The
problem is same which i mentioned you. It gives error on Anonymous
method(i.e; Delegate concept).In the last reply you told me to change
the signature of method.problem lies in MembershipUserODS file.
please have a look and try to correct the code.Thanks in advance.
================================MemebershipUserODS.vb file
=============================================================
Imports Microsoft.VisualBasic
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Collections
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Globalization
Imports System.Collections.ObjectModel
Namespace MembershipUtilities
''' <summary>
''' Class Used to Select, Update, Insert and Delete
''' From the Microsoft ASP.NET Membership API
''' </summary>
'''
<DataObject(True)> _
Public Class MembershipUserODS
''' <summary>
''' This insert method is the default insert method. It is
typically associated with
''' a detailview control for inserting new members.
''' </summary>
''' <param name="userName">MembershipUser.UserName</param>
''' <param name="password">MembershipUser.password</param>
''' <param name="isApproved">MembershipUser.IsApproved</param>
''' <param name="comment">MembershipUser.comment</param>
''' <param name="lastLockoutDate">MembershipUser.lastLockoutDate</
param>
''' <param name="creationDate">MembershipUser.creationDate</param>
''' <param name="email">MembershipUser.email</param>
''' <param name="lastActivityDate">MembershipUser.lastActivityDate</
param>
''' <param name="providerName">MembershipUser.providerName</param>
''' <param name="isLockedOut">MembershipUser.isLockedOut</param>
''' <param name="lastLoginDate">MembershipUser.lastLoginDate</param>
''' <param name="isOnline">MembershipUser.isOnline</param>
''' <param name="passwordQuestion">MembershipUser.passwordQuestion</
param>
''' <param
name="lastPasswordChangedDate">MembershipUser.lastPasswordChangedDate</
param>
'''
<DataObjectMethod(DataObjectMethodType.Insert, True)> _
Public Shared Sub Insert(ByVal userName As String, ByVal isApproved
As Boolean, ByVal comment As String, ByVal lastLockoutDate As
DateTime, ByVal creationDate As DateTime, ByVal email As String, ByVal
lastActivityDate As DateTime, ByVal providerName As String, ByVal
isLockedOut As Boolean, ByVal lastLoginDate As DateTime, ByVal
isOnline As Boolean, ByVal passwordQuestion As String, ByVal
lastPasswordChangedDate As DateTime, ByVal password As String, ByVal
passwordAnswer As String)
' The incoming parameters, password and passwordAnswer are not
properties of the
' MembershipUser class. Membership has special member functions to
deal with these
' two special properties for security reasons. For this reason,
they do not appear
' in a datacontrol that is created with this user object.
'
' the only reason you may want to have defaults is so you can build
insert into your
' datacontrol. A better approach would be to either follow the
example shown in the
' Membership.asp page where the parameters are set directly to the
userobject, or not
' include "new" at all in your control and use the other controls
in the Membership API
' for creating new members. (CreateUserWizard, etc)
'
' It is recommended that you only enable the following lines if you
are sure of what you are doing
'if (password == null)
'{
' password = "pass0word";
'}
'if (passwordAnswer == null)
'{
' passwordAnswer = "Password Answer";
'}
Dim status As MembershipCreateStatus
Membership.CreateUser(userName, password, email, passwordQuestion,
passwordAnswer, isApproved, status)
If status <> MembershipCreateStatus.Success Then
Throw New ApplicationException(status.ToString())
End If
Dim mu As MembershipUser = Membership.GetUser(userName)
mu.Comment = comment
Membership.UpdateUser(mu)
End Sub
''' <summary>
''' Takes as input the original username and the current username
''' </summary>
''' <param name="providerUserKey"></param>
''' <param name="Original_providerUserKey"></param>
'''
<DataObjectMethod(DataObjectMethodType.Delete, True)> _
Public Shared Sub Delete(ByVal UserName As String)
Membership.DeleteUser(UserName, True)
End Sub
''' <summary>
''' This update method is the default update as shown by the class
attribute.
'''
''' </summary>
''' <param name="original_UserName">MembershipUser.UserName
originally retrieved</param>
''' <param name="email">MembershipUser.email</param>
''' <param name="isApproved">MembershipUser.isApproved</param>
''' <param name="comment">MembershipUser.comment</param>
''' <param name="password">MembershipUser.password</param>
''' <param name="passwordAnswer">MembershipUser.passwordAnswer</
param>
''' <param name="lastActivityDate">MembershipUser.lastActivityDate</
param>
''' <param name="lastLoginDate">MembershipUser.lastLoginDate</param>
'''
<DataObjectMethod(DataObjectMethodType.Update, True)> _
Public Shared Sub Update(ByVal UserName As String, ByVal email As
String, ByVal isApproved As Boolean, ByVal comment As String, ByVal
lastActivityDate As DateTime, ByVal lastLoginDate As DateTime)
Dim dirtyFlag As Boolean = False
Dim mu As MembershipUser = Membership.GetUser(UserName)
If mu.Comment Is Nothing OrElse mu.Comment.CompareTo(comment) <> 0
Then
dirtyFlag = True
mu.Comment = comment
End If
If mu.Email Is Nothing OrElse mu.Email.CompareTo(email) <> 0 Then
dirtyFlag = True
mu.Email = email
End If
If mu.IsApproved <> isApproved Then
dirtyFlag = True
mu.IsApproved = isApproved
End If
If dirtyFlag = True Then
Membership.UpdateUser(mu)
End If
End Sub
''' <summary>
''' This is just used to set the IsApproved status.
''' username is always passed in for searching purposes.
''' </summary>
''' <param name="original_username">Current UserName to Update
(primary key)</param>
''' <param name="isApproved">MembershipUser.isApproved</param>
'''
<DataObjectMethod(DataObjectMethodType.Update, False)> _
Public Shared Sub Update(ByVal Username As String, ByVal isApproved
As Boolean)
Dim dirtyFlag As Boolean = False
Dim mu As MembershipUser = Membership.GetUser(Username)
If mu.IsApproved <> isApproved Then
dirtyFlag = True
mu.IsApproved = isApproved
End If
If dirtyFlag = True Then
Membership.UpdateUser(mu)
End If
End Sub
''' <summary>
''' Make a list of MembershipUserWrapper objects
''' </summary>
''' <returns>A List of type MembershipUserWrapper</returns>
'''
<DataObjectMethod(DataObjectMethodType.Select, False)> _
Public Shared Function GetMembers() As List(Of
MembershipUserWrapper)
Return GetMembers(True, True, Nothing, Nothing)
End Function
''' <summary>
''' Make a list of MembershipUserWrapper objects by current sort
''' </summary>
''' <param name="sortData">Whicfh Column to perform the sort on</
param>
''' <returns>A List of type MembershipUserWrapper</returns>
'''
<DataObjectMethod(DataObjectMethodType.Select, True)> _
Public Shared Function GetMembers(ByVal sortData As String) As
List(Of MembershipUserWrapper)
' All Users, All approvalStatus
Return GetMembers(True, True, Nothing, sortData)
End Function
''' <summary>
''' returns all approved users by specified sort
''' </summary>
''' <param name="approvalStatus">if true, return approved users</
param>
''' <param name="sortData">description of sort</param>
''' <returns>A List of type MembershipUserWrapper</returns>
'''
<DataObjectMethod(DataObjectMethodType.Select, False)> _
Public Shared Function GetMembers(ByVal approvalStatus As Boolean,
ByVal sortData As String) As List(Of MembershipUserWrapper)
If approvalStatus = True Then
Return GetMembers(True, False, Nothing, sortData)
Else
Return GetMembers(False, True, Nothing, sortData)
End If
End Function
''' <summary>
''' Return a collection of MembershipUserWrapper's based on criteria
passed in as parameters
''' </summary>
''' <param name="returnAllApprovedUsers">returns all users with
approval set to true</param>
''' <param name="returnAllNotApproviedUsers">return all users with
approval set to false</param>
''' <param name="usernameToFind">return based on username (overrides
approval above)</param>
''' <param name="sortData">sort parameter</param>
''' <returns>Returns a Collection of Users (as recommended by
FxCop)</returns>
'''
<DataObjectMethod(DataObjectMethodType.Select, False)> _
Public Shared Function GetMembers(ByVal returnAllApprovedUsers As
Boolean, ByVal returnAllNotApprovedUsers As Boolean, ByVal
usernameToFind As String, ByVal sortData As String) As List(Of
MembershipUserWrapper)
Dim memberList As List(Of MembershipUserWrapper) = New List(Of
MembershipUserWrapper)()
' See if we are looking for just one user
If usernameToFind IsNot Nothing Then
Dim mu As MembershipUser = Membership.GetUser(usernameToFind)
If mu IsNot Nothing Then
Dim md As New MembershipUserWrapper(mu)
memberList.Add(md)
End If
Else
Dim muc As MembershipUserCollection = Membership.GetAllUsers()
For Each mu As MembershipUser In muc
If (returnAllApprovedUsers = True AndAlso mu.IsApproved = True)
OrElse (returnAllNotApprovedUsers = True AndAlso mu.IsApproved =
False) Then
Dim md As New MembershipUserWrapper(mu)
memberList.Add(md)
End If
Next mu
If sortData Is Nothing Then
sortData = "UserName"
End If
If sortData.Length = 0 Then
sortData = "UserName"
End If
' Make a special version of sortData for the switch statement so
that whether or not the
' DESC is appended to the string sortData, it will switch on the
base of that string.
Dim sortDataBase As String = sortData ' init and assume there is
not DESC appended to sortData
Dim descString As String = " DESC"
If sortData.EndsWith(descString) Then
sortDataBase = sortData.Substring(0, sortData.Length -
descString.Length)
End If
Dim comparison As Comparison(Of MembershipUserWrapper) = Nothing
Select Case sortDataBase
Case "UserName"
comparison = New Comparison(Of MembershipUserWrapper)(AddressOf
AnonymousMethod1)
Case "Email"
comparison = New Comparison(Of MembershipUserWrapper)(AddressOf
AnonymousMethod2)
Case "CreationDate"
comparison = New Comparison(Of MembershipUserWrapper)(AddressOf
AnonymousMethod3)
Case "IsApproved"
comparison = New Comparison(Of MembershipUserWrapper)(AddressOf
AnonymousMethod4)
Case "IsOnline"
comparison = New Comparison(Of MembershipUserWrapper)(AddressOf
AnonymousMethod5)
Case "LastLoginDate"
comparison = New Comparison(Of MembershipUserWrapper)(AddressOf
AnonymousMethod6)
Case Else
comparison = New Comparison(Of MembershipUserWrapper)(AddressOf
AnonymousMethod7)
End Select
If sortData.EndsWith("DESC") Then
memberList.Sort(comparison)
memberList.Reverse()
Else
memberList.Sort(comparison)
End If
End If
' FxCopy will give us a warning about returning a List rather than
a Collection.
' We could copy the data, but not worth the trouble.
Return memberList
End Function
Private Shared Function AnonymousMethod1(ByVal lhs As
MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Integer
Return lhs.UserName.CompareTo(rhs.UserName)
End Function
Private Shared Function AnonymousMethod2(ByVal lhs As
MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Integer
If lhs.Email Is Nothing Or rhs.Email Is Nothing Then
Return 0
Else
Return lhs.Email.CompareTo(rhs.Email)
End If
End Function
Private Shared Function AnonymousMethod3(ByVal lhs As
MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
Return lhs.CreationDate.CompareTo(rhs.CreationDate)
End Function
Private Shared Function AnonymousMethod4(ByVal lhs As
MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
Return lhs.IsApproved.CompareTo(rhs.IsApproved)
End Function
Private Shared Function AnonymousMethod5(ByVal lhs As
MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
Return lhs.IsOnline.CompareTo(rhs.IsOnline)
End Function
Private Shared Function AnonymousMethod6(ByVal lhs As
MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
Return lhs.LastLoginDate.CompareTo(rhs.LastLoginDate)
End Function
Private Shared Function AnonymousMethod7(ByVal lhs As
MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
Return lhs.UserName.CompareTo(rhs.UserName)
End Function
End Class
End Namespace
===================================================end
file============================================================
=================================MembershipUserWrapper.vb
file=============================================================
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Collections.Generic
Imports System.ComponentModel
Namespace MembershipUtilities
''' <summary>
''' Summary description for MembershipUserWrapper
''' This class is inherited from MembershipUser
''' Using the sytax public class ClassName (..) :
base(initializers...) allows for calling the
''' contstructor of the base class. In this case MembershipUser.
''' </summary>
'''
Public Class MembershipUserWrapper
Inherits MembershipUser
''' <summary>
''' This constructor is used to create a MembershipUserWrapper
from a MembershipUser object. MembershipUser is a default type used
''' in the Membership API provided with ASP.NET 2.0
''' </summary>
''' <param name="mu">MembershipUser object</param>
Public Sub New(ByVal mu As MembershipUser)
MyBase.New(mu.ProviderName, mu.UserName,
mu.ProviderUserKey, mu.Email, mu.PasswordQuestion, mu.Comment, _
mu.IsApproved, mu.IsLockedOut, mu.CreationDate,
mu.LastLoginDate, mu.LastActivityDate, mu.LastPasswordChangedDate, _
mu.LastLockoutDate)
End Sub
''' <summary>
''' This calls the base class UserName property. It is here so
we can tag
''' this property as the primary key so that datakeynames
attribute gets set in the data control.
''' </summary>
'''
<DataObjectField(True)> _
Public Overloads Overrides ReadOnly Property UserName() As
String
Get
Return MyBase.UserName
End Get
End Property
''' <summary>
''' This constructor is used to create a MembershipUserWrapper
from individual parameters values.
''' For details of what each parameter means, see the
Microsoft Membership class.
''' </summary>
''' <param name="comment">Passes to MembershipUser.comment</
param>
''' <param name="creationDate">Passes to
MembershipUser.creationDate</param>
''' <param name="email">Passes to MembershipUser.email</param>
''' <param name="isApproved">Passes to
MembershipUser.isApproved</param>
''' <param name="lastActivityDate">Passes to
MembershipUser.lastActivityDate</param>
''' <param name="lastLoginDate">Passes to
MembershipUser.lastLoginDate</param>
''' <param name="passwordQuestion">Passes to
MembershipUser.passwordQuestion</param>
''' <param name="providerUserKey">Passes to
MembershipUser.providerUserKey</param>
''' <param name="userName">Passes to MembershipUser.userName</
param>
''' <param name="lastLockoutDate">Passes to
MembershipUser.lastLockoutDate</param>
''' <param name="providerName">Passes to
MembershipUser.providerName</param>
'''
Public Sub New(ByVal comment As String, ByVal creationDate As
DateTime, ByVal email As String, ByVal isApproved As Boolean, ByVal
lastActivityDate As DateTime, ByVal lastLoginDate As DateTime, _
ByVal passwordQuestion As String, ByVal providerUserKey As
Object, ByVal userName As String, ByVal lastLockoutDate As DateTime,
ByVal providerName As String)
' This calls a constructor of MembershipUser automatically
because of the base reference above
MyBase.New(providerName, userName, providerUserKey, email,
passwordQuestion, comment, _
isApproved, False, creationDate, lastLoginDate,
lastActivityDate, DateTime.Now, _
lastLockoutDate)
End Sub
End Class
End Namespace
=====================================end
file=======================================================================
please try to provide me the solution ASAP. Thanks!