Xamarin.ios Monotouch:如何获得此方法的可寻址性?
在不同的.cs文件中有两种方法。尝试从文件2访问位于文件1中的DisplayReport时,出现以下错误: 错误CS0120:访问非静态成员'Prager.AppDelegate.DisplayReport'需要对象引用 此代码位于文件1中:Xamarin.ios Monotouch:如何获得此方法的可寻址性?,xamarin.ios,Xamarin.ios,在不同的.cs文件中有两种方法。尝试从文件2访问位于文件1中的DisplayReport时,出现以下错误: 错误CS0120:访问非静态成员'Prager.AppDelegate.DisplayReport'需要对象引用 此代码位于文件1中: public partial class AppDelegate { public static string html; public void DisplayReport() { if(selectedS
public partial class AppDelegate
{
public static string html;
public void DisplayReport() {
if(selectedSiteID == null) {
errorAlert ea = new errorAlert();
在文件2中,我有以下代码:
private void SendViaEmail() {
byte[] data = File.ReadAllBytes(filePath);
NSData datas = NSData.FromArray(data);
string[] receipients = {txtEmailAddress.Text};
if (MFMailComposeViewController.CanSendMail) {
_mail = new MFMailComposeViewController();
if(html != null)
_mail.SetMessageBody(html,true); // indicate the body is html
else {
AppDelegate.DisplayReport(); // <--error here
}
您的DisplayReport方法需要是静态的,才能以这种方式访问:
public static void DisplayReport() {}
我试过了。。然后我得到了十几个其他的可寻址性错误,比如:访问非静态成员'Prager.AppDelegate.lblDESiteID'cs0120需要一个对象引用。我发现了,我希望。。。谢谢你的帮助。。。我很感激!你好,斯波坎·杜德,请注意您为解决此问题所做的工作,以使其对其他人有用。