C#看不到的VB.NET属性 [英] VB.NET properties not seen by c#

查看:84
本文介绍了C#看不到的VB.NET属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#中使用vb.net类进行AD身份验证.我的问题是它无法为C#中的用户读取我的属性.在VB.NET中对其进行修复以使其可见的正确方法是什么,或者有人可以在C#中提供一个有关如何重写它的示例?

它是一个VB.NET类,但似乎可以访问大多数(如果不是全部),但是似乎无法检索_theUser.即使我可以访问ADSecurity.UserCredentials类并查看该类中的某些项目,它始终为null.也可能是Session没有被填充吗?含义Session ["thisUser"]定义不正确或定义不正确?

将公共ReadOnly属性UserId()作为字符串
获取
返回_userId
结束获取
最终财产
以下C#看不到用户属性,并以_theUser返回null.

受保护的void Page_Load(对象发送者,EventArgs e)
{
如果(!IsPostBack)
{

_theUser =(ADSecurity.UserCredentials)Session ["thisUser"];
如果(_theUser.IsValidUser)
{
如果(_theUser.IsAdminGroup | _theUser.IsManagersGroup | _theUser.IsProjManagersGroup | _theUser.IsProduction | _theUser.IsSales | _theUser.IsFlight | _theUser.IsSupport)
{


}

I have a vb.net class I am using in C# for AD authentication. My problem is its not able to read my properites for the user in C#. What would be the properway to fix it in VB.NET to make it seen or can someone provide an example in C# of how I could rewrite it?

Its a VB.NET class but it seems to access most if not all but can''t seem to retrieve the _theUser. It''s always null even though I can access the ADSecurity.UserCredentials class and view some the items in the Class. Could it also be that maybe Session is not being populated? Meaning Session["thisUser"]is not defined or defined correctly?

Public ReadOnly Property UserId() As String
Get
Return _userId
End Get
End Property
The following C# is where it can''t see the user properties and comes back with _theUser as null.

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{

_theUser = (ADSecurity.UserCredentials)Session["thisUser"];
if (_theUser.IsValidUser)
{
if (_theUser.IsAdminGroup | _theUser.IsManagersGroup | _theUser.IsProjManagersGroup | _theUser.IsProduction | _theUser.IsSales | _theUser.IsFlight | _theUser.IsSupport)
{


}

推荐答案

您可能想要查看包含该类的文件的位置. Visual Studio根据在目录中找到的语言对语言进行假设.
You might want to look at where the file containing the class is. Visual Studio makes assumptions about language depending on what it finds in a directory.


好,引用dll并添加名称空间. C#类在VB.NET中的作用相同.

您不需要将C#代码转换为vb.net,因为它们都产生相同的IL.

如果看不到某个属性,则定义该属性时使用的访问说明符是不够的. ;)
Well, reference to the dll and add the namespace. The C# class will act just the same in VB.NET.

You dont need to convert C# code to vb.net as both of them produces same IL.

If a property cant be seen, then the access specifier used when defining the property is not enough. ;)


这篇关于C#看不到的VB.NET属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆