我创建了一个游戏,其中包含了另一个类中列出的许多方法...... 所以我想全局使用这个类,所以我将它存储在DLL中(以便能够在其他几个项目中使用它)
但不知何故,Visual Studio没有找到我引用的DLL的命名空间!
我做错了什么吗? 'fncs'DLL的命名空间也称为'fncs'... 它们都是在相同版本的.NET中创建的...... 提前谢谢!
DLL:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
using System.Runtime.InteropServices;
namespace fncs {
class io {
public static bool write(string dir, object[] obj) {
try {
File.WriteAllLines(dir, ((System.Collections.IEnumerable)obj).Cast<object>().Select(x => x.ToString()).ToArray());
} catch (Exception e) {
return false;
} return true;
}
public static string read(string dir) {
StreamReader r = new StreamReader(dir);
return r.ReadToEnd();
}
public static void saveToServer(string x, string y) {
// hidden
}
}
class rc {
public static void echo(object obj) {
Console.WriteLine(obj.ToString());
}
public static string get() {
return Console.ReadLine();
}
}
class math {
public static int add(int a, int b) {
return a + b;
}
}
class web {
public static string getWebContent(string url) {
WebClient c = new WebClient();
string s;
try {
s = c.DownloadString(url);
} catch (WebException w) {
return w.ToString();
} return s;
}
public static string OpenSQL() {
SQLConnection SQL = new SQLConnection();
return SQL.BindStatus();
}
public static string post(string Url, params string[] postdata) {
string result = string.Empty;
string data = string.Empty;
System.Text.ASCIIEncoding ascii = new ASCIIEncoding();
if (postdata.Length % 2 != 0) {
Console.WriteLine("Parameters must be even , \"user\" , \"value\" , ... etc");
return string.Empty;
}
for (int i = 0; i < postdata.Length; i += 2) {
data += string.Format("&{0}={1}", postdata[i], postdata[i + 1]);
}
data = data.Remove(0, 1);
byte[] bytesarr = ascii.GetBytes(data);
try {
WebRequest request = WebRequest.Create(Url);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = bytesarr.Length;
System.IO.Stream streamwriter = request.GetRequestStream();
streamwriter.Write(bytesarr, 0, bytesarr.Length);
streamwriter.Close();
WebResponse response = request.GetResponse();
streamwriter = response.GetResponseStream();
System.IO.StreamReader streamread = new System.IO.StreamReader(streamwriter);
result = streamread.ReadToEnd();
streamread.Close();
} catch (Exception ex) {
Console.WriteLine(ex.Message);
}
return result;
}
}
class SQLConnection {
public string conn_bind;
public SQLConnection() {
//hidden
}
public string BindStatus() {
return conn_bind;
}
}
}
答案 0 :(得分:5)
---- ----更新
你的班级需要公开。默认值为internal,表示只能在程序集中查看。一旦将其公开并重建,您的其他项目就应该看到它。