获取成员的C#WebApp程序无法使用VB类的实例引用进行访问 [英] C# WebApp program getting Member … cannot be accessed with an instance reference from a VB Class

查看:116
本文介绍了获取成员的C#WebApp程序无法使用VB类的实例引用进行访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个引用VB(2013)电话的C#(2013)网络应用程序。但是当试图访问变量和属性时,我们得到一个'成员......无法通过实例引用访问'



C#has

APIV3VS2013.APIV3Cl aCl = new APIV3VS2013.APIV3Cl();



aCl.TheAccessToken = TheAccessToken;

aCl.TheAccessTokenSecret = TheAccessTokenSecret



获取上述两个错误。



在VB Dll中我们有





公共共享属性TheAccessTokenSecret As String

公共共享TheAccessToken作为String



我一直在玩物业,公共,共享等。



应该如何被编码为没有得到错误?

We have a C# (2013) web app program that references a VB (2013) call. But when trying to access variable and properties we get an 'member ... cannot be accessed with an instance reference'

C# has
APIV3VS2013.APIV3Cl aCl = new APIV3VS2013.APIV3Cl();
.
aCl.TheAccessToken = TheAccessToken;
aCl.TheAccessTokenSecret = TheAccessTokenSecret

Gets errors on both of the above.

In the VB Dll we have


Public Shared Property TheAccessTokenSecret As String
Public Shared TheAccessToken As String

I have been playing with Property, Public, Shared, etc.

How should it be coded to not get the error?

推荐答案

这是因为
Shared

关键字。在C#中,转换为

keyword. In C# that translates into

static

,因此无法在实例引用上访问它。您必须像C#中的静态属性一样访问它:

and as such it cannot be accessed on the instance reference. You'd have to access it like a static property in C#:

APIV3VS2013.TheAccessToken = TheAccessToken; 


你是对的。



我删除了静态它似乎工作但我我试图找出应该从Windows桌面进行编码的最佳方式,其中只有1个用户到Web应用程序,同时有超过1个用户。



这包括:

1.为应用程序修复的OAuth使用者密钥和密钥,我假设为静态/共享。

2. OAuth访问密钥和每个用户的秘密,我认为不是静态/共享。



因此,只有静态/共享变量是应用程序独有的变量和其他任何内容才是正确的(主要与用户有关)不是静态/共享?
You were correct.

I have removed the Static and it seems to work but I am trying to figure out the best way it should be coded going from Windows Desktop where there is only 1 users to a Web App where there will be more than 1 at the same time.

This would include:
1. OAuth Consumer Key and Secret which are fixed for the app and I assume static/shared.
2. OAuth Access Key and Secret which are per user and I assume not static/shared.

So is it correct that only Static/Shared variables are those that are unique to the App and anything else (mostly related to the user would) not be Static/Shared?


这篇关于获取成员的C#WebApp程序无法使用VB类的实例引用进行访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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