Wednesday, March 28, 2012

strange compile error!

Hey
asp.net 2.0
This line of code:
MembershipUserCollection onlineUsers = Membership.GetAllUsers;
In this script:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class MasterPages_ContentMaster : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
MembershipUserCollection onlineUsers = Membership.GetAllUsers;
}
}
}
Gives this compile error:
Error 2 Cannot convert method group 'GetAllUsers' to non-delegate type
'System.Web.Security.MembershipUserCollection'. Did you intend to invoke the
method? C:\Documents and Settings\Jeff\My Documents\Visual Studio
2005\WebSites\Helloworld\MasterPages\Con
tentMaster.master.cs 20 52
C:\...\Helloworld\
The code is placed in a master page...
I don't understand what I'm doing wrong here...
Any suggestions?Its a method, you need some parenthesis there.
http://msdn2.microsoft.com/en-us/library/dy8swhya.aspx
Jeff wrote:
> Hey
> asp.net 2.0
> This line of code:
> MembershipUserCollection onlineUsers = Membership.GetAllUsers;
> In this script:
> using System;
> using System.Data;
> using System.Configuration;
> using System.Collections;
> using System.Web;
> using System.Web.Security;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.Web.UI.WebControls.WebParts;
> using System.Web.UI.HtmlControls;
> public partial class MasterPages_ContentMaster : System.Web.UI.MasterPage
> {
> protected void Page_Load(object sender, EventArgs e)
> {
> if (!this.IsPostBack)
> {
> MembershipUserCollection onlineUsers = Membership.GetAllUsers;
> }
> }
> }
> Gives this compile error:
> Error 2 Cannot convert method group 'GetAllUsers' to non-delegate type
> 'System.Web.Security.MembershipUserCollection'. Did you intend to invoke t
he
> method? C:\Documents and Settings\Jeff\My Documents\Visual Studio
> 2005\WebSites\Helloworld\MasterPages\Con
tentMaster.master.cs 20 52
> C:\...\Helloworld\
> The code is placed in a master page...
> I don't understand what I'm doing wrong here...
> Any suggestions?
"Jeff" <it_consultant1@.hotmail.com.NOSPAM> wrote in message
news:eKM4DMM7GHA.1496@.TK2MSFTNGP05.phx.gbl...
> This line of code:
> MembershipUserCollection onlineUsers = Membership.GetAllUsers;

> Gives this compile error:
> Error 2 Cannot convert method group 'GetAllUsers' to non-delegate type
[...]
You're going to laugh (or cry):
MembershipUserCollection onlineUsers = Membership.GetAllUsers();
Having that "()" there is what you need. This drove me nuts for a while, as
VB.Net doesn't need it and I got in the habit of omitting it.
Chris Mullins, MCSD.NET, MCPD:Enterprise
http://www.coversant.net/blogs/cmullins
solved, GetAllUsers is a method, not a property...
"Jeff" <it_consultant1@.hotmail.com.NOSPAM> wrote in message
news:eKM4DMM7GHA.1496@.TK2MSFTNGP05.phx.gbl...
> Hey
> asp.net 2.0
> This line of code:
> MembershipUserCollection onlineUsers = Membership.GetAllUsers;
> In this script:
> using System;
> using System.Data;
> using System.Configuration;
> using System.Collections;
> using System.Web;
> using System.Web.Security;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.Web.UI.WebControls.WebParts;
> using System.Web.UI.HtmlControls;
> public partial class MasterPages_ContentMaster : System.Web.UI.MasterPage
> {
> protected void Page_Load(object sender, EventArgs e)
> {
> if (!this.IsPostBack)
> {
> MembershipUserCollection onlineUsers = Membership.GetAllUsers;
> }
> }
> }
> Gives this compile error:
> Error 2 Cannot convert method group 'GetAllUsers' to non-delegate type
> 'System.Web.Security.MembershipUserCollection'. Did you intend to invoke
> the method? C:\Documents and Settings\Jeff\My Documents\Visual Studio
> 2005\WebSites\Helloworld\MasterPages\Con
tentMaster.master.cs 20 52
> C:\...\Helloworld\
> The code is placed in a master page...
> I don't understand what I'm doing wrong here...
> Any suggestions?
>

0 comments:

Post a Comment