Showing posts with label compile. Show all posts
Showing posts with label compile. Show all posts

Wednesday, March 28, 2012

Strange compile problem

I am compiling a simple application and am getting these types of errors:

Type 'EventArgs' is not defined.
Type 'Exception' is not defined.
Type 'Int32' is not defined.
Type 'Type' is not defined.
Name 'Convert' is not declared.

It seems as if the compiler is not including the System.dll (which is obviously referenced in the project). I have tried deleting the bin directory and removing the cache, but nothing helps.

Any ideas?

Thanks,

AndrewLooks like one of the System.* is missing, but is very difficult to tell which one
It looks to me like you haven't declared that you are using the System namespace at the top of your file:

using System;

I have the following references showing:
System
System.Data
System.Design
System.Drawing
System.Web
System.Windows.Forms
System.XML
No, that is not required in vb.

Andrew

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\ContentMaster .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:

Quote:

Originally Posted by

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\ContentMaster .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.NOSPAMwrote in message
news:eKM4DMM7GHA.1496@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

This line of code:
MembershipUserCollection onlineUsers = Membership.GetAllUsers;


Quote:

Originally Posted by

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.NOSPAMwrote in message
news:eKM4DMM7GHA.1496@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

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\ContentMaster .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?
>

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?
>