方法、参数和成员变量,在 Windows 中无法访问到 Mono 端口
Methods, arguments, and member variables, not accessible in Windows to Mono port
我在 SO 上找不到这个地址。我正在将一个 Windows .NET 应用程序移植到 Linux 上的 Mono,它可以完美地编译和运行。我错过了一些小东西。这是代码的一部分:
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SQLite;
using System.Text.RegularExpressions;
using System.Windows.Forms;
namespace DAPTimeClock
{
public static class DatabaseOps
{
private static string _dbFile;
public static string Get_dbFile()
{
return _dbFile;
}
public void Set_dbFile(string value)
{
this._dbFile = value;
}
public static bool foundFile = false;
public static string SetFile(String dblocation = @"Data" +
"Source=../db/TimeClock.db; Version=3;")
{
Set_dbFile( dblocation );
int pathStart = Get_dbFile().IndexOf ('=') + 1;
int pathEnd = Get_dbFile().IndexOf (";") - 1;
string filePath = Get_dbFile().Substring (pathStart,
pathEnd - pathStart + 1);
if (File.Exists (filePath)) {
foundFile = true;
return string.Format ("The db file {0} has been " +
"located", filePath);
} else
{
foundFile = false;
return string.Format("Unable to find db file {0}.",
filePath);
}
}
public static bool AddPerson(Person p)
{
bool result = false;
Class Continues .....
问题如下:
- 其他 classes 无法从这个 class 中找到任何方法。前任。 DatabaseOp.Set_dbFile() 没有这样的方法。
- 此 class 中的方法无法从此 class 中找到方法。
- 这个class里面的方法看不到外面classes.
- 如果我将参数传递给 class 中的方法,编译器会说找不到该名称的参数。
- class中的方法看不到自己的成员变量。
我做了以下事情:
- 我删除了静态,现在制作常规对象。 (没有变化)
- 我仔细检查了命名空间。 (都一样,没有错别字)
- 我尝试制作成员变量public并添加一个get;并设置;
我很难过。任何人都可以看到可能挂起的是什么吗?我错过了关于单声道的东西吗?所有其他 classes 都工作正常。
Set_dbFile 应声明为
public static void Set_dbFile(string value)
编译器应该抱怨:"cannot declare instance members in static class"。你错过了吗?
我在 SO 上找不到这个地址。我正在将一个 Windows .NET 应用程序移植到 Linux 上的 Mono,它可以完美地编译和运行。我错过了一些小东西。这是代码的一部分:
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SQLite;
using System.Text.RegularExpressions;
using System.Windows.Forms;
namespace DAPTimeClock
{
public static class DatabaseOps
{
private static string _dbFile;
public static string Get_dbFile()
{
return _dbFile;
}
public void Set_dbFile(string value)
{
this._dbFile = value;
}
public static bool foundFile = false;
public static string SetFile(String dblocation = @"Data" +
"Source=../db/TimeClock.db; Version=3;")
{
Set_dbFile( dblocation );
int pathStart = Get_dbFile().IndexOf ('=') + 1;
int pathEnd = Get_dbFile().IndexOf (";") - 1;
string filePath = Get_dbFile().Substring (pathStart,
pathEnd - pathStart + 1);
if (File.Exists (filePath)) {
foundFile = true;
return string.Format ("The db file {0} has been " +
"located", filePath);
} else
{
foundFile = false;
return string.Format("Unable to find db file {0}.",
filePath);
}
}
public static bool AddPerson(Person p)
{
bool result = false;
Class Continues .....
问题如下:
- 其他 classes 无法从这个 class 中找到任何方法。前任。 DatabaseOp.Set_dbFile() 没有这样的方法。
- 此 class 中的方法无法从此 class 中找到方法。
- 这个class里面的方法看不到外面classes.
- 如果我将参数传递给 class 中的方法,编译器会说找不到该名称的参数。
- class中的方法看不到自己的成员变量。
我做了以下事情:
- 我删除了静态,现在制作常规对象。 (没有变化)
- 我仔细检查了命名空间。 (都一样,没有错别字)
- 我尝试制作成员变量public并添加一个get;并设置;
我很难过。任何人都可以看到可能挂起的是什么吗?我错过了关于单声道的东西吗?所有其他 classes 都工作正常。
Set_dbFile 应声明为
public static void Set_dbFile(string value)
编译器应该抱怨:"cannot declare instance members in static class"。你错过了吗?