Cannot acces non-static method in static context

Hi

I have setup an attribute to redirect the user to a specific action of a 
specific controller whenever the session has expired.
I want to specify this in 1 location and use a global filter, so I made a 
parameterless constructor for it like so:

public class SessionExpiredAttribute : CheckSessionExpiredAttribute
{
     public SessionExpiredAttribute() : base("SessionExpired", "Home")
     {
     }
}

public CheckSessionExpiredAttribute( string 
actionName, string controllerName)
{
     ...
     Code
     ...
}

R# gives me an error: Cannot access non-static method 'SessionExpired' in 
static context.

I understand the method is not static and in the constructor the instance 
should not yet be used, but its not really a method call its a routing 
reference.

I think this is a bug in R#.

Arnold Nelisse

3 comments

Hello Arnold,

Could you please attach a small sample solution demonstrating this problem?
Thank you!

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Hi

I have setup an attribute to redirect the user to a specific action of
a
specific controller whenever the session has expired.
I want to specify this in 1 location and use a global filter, so I
made a
parameterless constructor for it like so:
public class SessionExpiredAttribute : CheckSessionExpiredAttribute
{
public SessionExpiredAttribute() : base("SessionExpired", "Home")
{
}
}
public CheckSessionExpiredAttribute( string
actionName, string controllerName)
{
...
Code
...
}
R# gives me an error: Cannot access non-static method 'SessionExpired'
in  static context.

I understand the method is not static and in the constructor the
instance  should not yet be used, but its not really a method call its
a routing  reference.

I think this is a bug in R#.

Arnold Nelisse



0

Yes. I made a test solution.
Go to the class MySessionExpiredAttribute.cs

You can rightclick to the correct action, but resharper gives the error:  
Cannot access non-static method 'SessionExpired'

Example is same as below, but I forgot the surrounding class. Sorry about 
that.

Arnold Nelisse


Op Fri, 06 May 2011 12:17:27 +0200 schreef Andrew Serebryansky 
<andrew.serebryansky@jetbrains.com>:

Hello Arnold,

>

Could you please attach a small sample solution demonstrating this 
problem? Thank you!

>

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

>
>> Hi
>>  I have setup an attribute to redirect the user to a specific action of
>> a
>> specific controller whenever the session has expired.
>> I want to specify this in 1 location and use a global filter, so I
>> made a
>> parameterless constructor for it like so:
>> public class SessionExpiredAttribute : CheckSessionExpiredAttribute
>> {
>> public SessionExpiredAttribute() : base("SessionExpired", "Home")
>> {
>> }
>> }
>> public CheckSessionExpiredAttribute( string
>> actionName, string controllerName)
>> {
>> ...
>> Code
>> ...
>> }
>> R# gives me an error: Cannot access non-static method 'SessionExpired'
>> in  static context.
>>  I understand the method is not static and in the constructor the
>> instance  should not yet be used, but its not really a method call its
>> a routing  reference.
>>  I think this is a bug in R#.
>>  Arnold Nelisse
>>
>

0

Hello Arnold,

Thank you! I've logged a bug-report and you're welcome to monitor its status
at http://youtrack.jetbrains.net/issue/RSRP-262244.

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Yes. I made a test solution.
Go to the class MySessionExpiredAttribute.cs
You can rightclick to the correct action, but resharper gives the
error:   Cannot access non-static method 'SessionExpired'

Example is same as below, but I forgot the surrounding class. Sorry
about  that.

Arnold Nelisse

Op Fri, 06 May 2011 12:17:27 +0200 schreef Andrew Serebryansky
<andrew.serebryansky@jetbrains.com>:

>> Hello Arnold,
>>
>> Could you please attach a small sample solution demonstrating this
>> problem? Thank you!
>>
>> Andrey Serebryansky
>> Senior Support Engineer
>> JetBrains, Inc
>> http://www.jetbrains.com
>> "Develop with pleasure!"
>>> Hi
>>> I have setup an attribute to redirect the user to a specific action
>>> of
>>> a
>>> specific controller whenever the session has expired.
>>> I want to specify this in 1 location and use a global filter, so I
>>> made a
>>> parameterless constructor for it like so:
>>> public class SessionExpiredAttribute : CheckSessionExpiredAttribute
>>> {
>>> public SessionExpiredAttribute() : base("SessionExpired", "Home")
>>> {
>>> }
>>> }
>>> public CheckSessionExpiredAttribute( string
>>> actionName, string controllerName)
>>> {
>>> ...
>>> Code
>>> ...
>>> }
>>> R# gives me an error: Cannot access non-static method
>>> 'SessionExpired'
>>> in  static context.
>>> I understand the method is not static and in the constructor the
>>> instance  should not yet be used, but its not really a method call
>>> its
>>> a routing  reference.
>>> I think this is a bug in R#.
>>> Arnold Nelisse


0

Please sign in to leave a comment.