|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
What exactly does this message mean?I have VS2005 installed on my destop and on my laptop. I created this app
with my desktop and i don't get this. Run the IDE on my laptop and this is what I get? Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated. "Brian Shafer" <BrianSha***@discussions.microsoft.com> schrieb: You are attempting to access a member which is marked as 'Shared' using a >I have VS2005 installed on my destop and on my laptop. I created this app > with my desktop and i don't get this. Run the IDE on my laptop and this is > what I get? > > Access of shared member, constant member, enum member or nested type > through > an instance; qualifying expression will not be evaluated. reference referencing an instance of the type. Instead, simply write '<type name>.<member name>'. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> I just want to make a comment, I am not sure what the error refers to,
however, I have seen similiar warning signs on some of the programs I have written. Example, If I want to sort an array, I would assume I could use syntax such as: MyArray.Sort(MyArray) This would cause the same warning that you have mentioned, but if I change my syntax to something like: system.Array.Sort(MyArray) and the error warning would go away. I personally think its a coding issue, you might want to check to see if both of your programs are referencing the same NameSpaces (import statements). Herfried K. Wagner [MVP] wrote: Show quoteHide quote > "Brian Shafer" <BrianSha***@discussions.microsoft.com> schrieb: > >I have VS2005 installed on my destop and on my laptop. I created this app > > with my desktop and i don't get this. Run the IDE on my laptop and this is > > what I get? > > > > Access of shared member, constant member, enum member or nested type > > through > > an instance; qualifying expression will not be evaluated. > > You are attempting to access a member which is marked as 'Shared' using a > reference referencing an instance of the type. Instead, simply write '<type > name>.<member name>'. > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://dotnet.mvps.org/dotnet/faqs/> It is the same source code... just copied to my laptop...
Show quoteHide quote "JimmyKoolPantz" wrote: > I just want to make a comment, I am not sure what the error refers to, > however, I have seen similiar warning signs on some of the programs I > have written. Example, If I want to sort an array, I would assume I > could use syntax such as: > > MyArray.Sort(MyArray) > > This would cause the same warning that you have mentioned, but if I > change my syntax to something like: > > system.Array.Sort(MyArray) and the error warning would go away. > > I personally think its a coding issue, you might want to check to see > if both of your programs are referencing the same NameSpaces (import > statements). > > > Herfried K. Wagner [MVP] wrote: > > "Brian Shafer" <BrianSha***@discussions.microsoft.com> schrieb: > > >I have VS2005 installed on my destop and on my laptop. I created this app > > > with my desktop and i don't get this. Run the IDE on my laptop and this is > > > what I get? > > > > > > Access of shared member, constant member, enum member or nested type > > > through > > > an instance; qualifying expression will not be evaluated. > > > > You are attempting to access a member which is marked as 'Shared' using a > > reference referencing an instance of the type. Instead, simply write '<type > > name>.<member name>'. > > > > -- > > M S Herfried K. Wagner > > M V P <URL:http://dotnet.mvps.org/> > > V B <URL:http://dotnet.mvps.org/dotnet/faqs/> > >
Show quote
Hide quote
> It is the same source code... just copied to my laptop... You are probably seeing the FxCop rules being run where they aren't run on >>> "Brian Shafer" <BrianSha***@discussions.microsoft.com> schrieb: >>> >>>> I have VS2005 installed on my destop and on my laptop. I created >>>> this app with my desktop and i don't get this. Run the IDE on my >>>> laptop and this is what I get? >>>> >>>> Access of shared member, constant member, enum member or nested >>>> type >>>> through >>>> an instance; qualifying expression will not be evaluated. >>> You are attempting to access a member which is marked as 'Shared' >>> using a reference referencing an instance of the type. Instead, >>> simply write '<type name>.<member name>'. your other computer's IDE (pre 2005 or without the Code Analysis turned on in the project). Here's an explanation of the issue. Let's say you have a class called foo with a shared method bar as follows: Public Class Foo Public Shared Sub Bar() 'Do Something End Sub End Class Now, lets consider how you call this method. You can not have a calling method that calls Bar on an instance of Foo as follows: Public Sub Main() Dim instance as new Foo instance.Bar 'This is invalid End Sub Instead, you need to call Bar directly without an instance as follows: Public Sub Main() Foo.Bar() End Sub Sometimes, you can end up with conflicts in namespaces and although you think you are calling the shared method directly, you are trying to call it from an instance as follows: Public Sub Main() Dim foo as new Foo foo.Bar() 'Incorrect MyApp.Foo.Bar() 'Correct assuming MyApp is the namespace for the application. End Sub I hope this helps you understand the situation. Typically, this is a relatively easy oversight to make and luckily fix as well. Jim Wooley http://devauthority.com/blogs/jwooley/default.aspx > MyArray.Sort(MyArray) The difference in these statements is that MyArray is a variable, so it may > system.Array.Sort(MyArray) and the error warning would go away. be nothing and null reference exception occurs. Of course, this is a bad example since the same variable is used as parameter as well, so an exception would actually be thrown in both cases, but you got the point? -h- "Heikki Leivo" <heikkidotleivo@cadworksdotfi.removethis> schrieb: Note that 'Array.Sort' is a shared method, so it can eben be called on a >> MyArray.Sort(MyArray) >> system.Array.Sort(MyArray) and the error warning would go away. > > The difference in these statements is that MyArray is a variable, so it > may be nothing and null reference exception occurs. Of course, this is a > bad example since the same variable is used as parameter as well, so an > exception would actually be thrown in both cases, but you got the point? 'Nothing' reference. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> > Note that 'Array.Sort' is a shared method, so it can eben be called on a Well, thanks for correcting. This ain't my first time being wrong. I have > 'Nothing' reference. always thought that this was the true meaning of the mentioned error message. -h-
How can I use a dll with several programs?
vb2005 and ce net 4.2 books for vb.net Binding Data to Dataset or Table DatagridView Column Headers Are codes ran in try blocks expensive? in VB, String '=' is two orders of magnitude slower than .Equals! disable/enable menu items sqlexpress WebBrowser Control Issue |
|||||||||||||||||||||||