将变量或 属性 传递给共享方法时出错
Error when passing variable or property to shared method
我有一个关于 public 共享方法的查询,我有一个错误指示 BC30369:无法从共享方法引用 class 的实例成员。
我的错误是:
strUsuarioapp = ucase (user.identity.Name.split ("\") (0))
正好在 user
行 ucase(user.identity.Name.split ("\") (0))
returns 我需要的数据(域用户),我尝试使用另一个 ucase(system.environment.usernane)
,但是根据环境它给了我不同的值,而 user.identity.Name
不会让我失望.
我理解错误参考,但我不知道如何传递值,必须共享该方法。
我无法从方法中删除共享,是否有任何代码可以将 user.identity.Name
的值传递给它而不给我一个错误?代码:
public class frmview1
inherits system.web.ui.page
public pstruserApp as string
public property strUsuarioapp () as string
get
return pstruserapp
end get
set (value as string)
pstrUsuarioapp = value
end set
end property
public shared function usercall (byval name as string, byval namev as string) as string
dim strUsuarioapp = ucase (user.identity.Name.split ("\") (0))
' Error here
' ....
' ....
return strresult
end function
将用户参数添加到您的函数
pubic shared function usercall (byref System.Security.Principal.Principal user, byval name as string, byval namev as string) as string
dim strUsuarioapp = ucase (user.identity.Name.split ("\") (0))
'here Err
....
......
return strresult
end function
我有一个关于 public 共享方法的查询,我有一个错误指示 BC30369:无法从共享方法引用 class 的实例成员。
我的错误是:
strUsuarioapp = ucase (user.identity.Name.split ("\") (0))
正好在 user
行 ucase(user.identity.Name.split ("\") (0))
returns 我需要的数据(域用户),我尝试使用另一个 ucase(system.environment.usernane)
,但是根据环境它给了我不同的值,而 user.identity.Name
不会让我失望.
我理解错误参考,但我不知道如何传递值,必须共享该方法。
我无法从方法中删除共享,是否有任何代码可以将 user.identity.Name
的值传递给它而不给我一个错误?代码:
public class frmview1
inherits system.web.ui.page
public pstruserApp as string
public property strUsuarioapp () as string
get
return pstruserapp
end get
set (value as string)
pstrUsuarioapp = value
end set
end property
public shared function usercall (byval name as string, byval namev as string) as string
dim strUsuarioapp = ucase (user.identity.Name.split ("\") (0))
' Error here
' ....
' ....
return strresult
end function
将用户参数添加到您的函数
pubic shared function usercall (byref System.Security.Principal.Principal user, byval name as string, byval namev as string) as string
dim strUsuarioapp = ucase (user.identity.Name.split ("\") (0))
'here Err
....
......
return strresult
end function