Test1是个我自己建的类、我需要用到里面的AAA方法 但是一直抱着个错误
看你Test1类所在命名空间,最好发一下代码
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
namespace OThinker.H3.Portal.Sheets.DefaultEngine
{
public class Test1
{
public ERPResulModel AAA(string ServerPage, string workflowCode, string userCode, bool finishStart, rec[] list)
{
string postData = "workflowCode=" + workflowCode + "userCode=" + userCode + "finishStart=" + finishStart+ "paramValues="+list;
byte[] dataArray = Encoding.Default.GetBytes(postData);
//创建请求
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(ServerPage);
request.Method = "POST";
request.ContentLength = dataArray.Length;
request.ContentType = "application/x-www-form-urlencoded";
//创建输入流
Stream dataStream = null;
try
{
dataStream = request.GetRequestStream();
}
catch (Exception)
{
return null;//连接服务器失败
}
//发送请求
dataStream.Write(dataArray, 0, dataArray.Length);
dataStream.Close();
//读取返回消息
ERPResulModel resultModel = "";
try
{
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.Default);
resultModel = reader.ReadToEnd();
reader.Close();
}
catch (Exception ex)
{
return null;//连接服务器失败
}
return resultModel;
}
}
@素雅淡生丶: new Test1() 引入OThinker.H3.Portal.Sheets.DefaultEngine这个命名空间,或者在Test1前面加上OThinker.H3.Portal.Sheets.DefaultEngine这个命名空间
你看看你那个类里面的命名是Test1吗,或者你引用一下放Test1的那个层。
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
namespace OThinker.H3.Portal.Sheets.DefaultEngine
{
public class Test1
{
public ERPResulModel AAA(string ServerPage, string workflowCode, string userCode, bool finishStart, rec[] list)
{
string postData = "workflowCode=" + workflowCode + "userCode=" + userCode + "finishStart=" + finishStart+ "paramValues="+list;
byte[] dataArray = Encoding.Default.GetBytes(postData);
//创建请求
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(ServerPage);
request.Method = "POST";
request.ContentLength = dataArray.Length;
request.ContentType = "application/x-www-form-urlencoded";
//创建输入流
Stream dataStream = null;
try
{
dataStream = request.GetRequestStream();
}
catch (Exception)
{
return null;//连接服务器失败
}
//发送请求
dataStream.Write(dataArray, 0, dataArray.Length);
dataStream.Close();
//读取返回消息
ERPResulModel resultModel = "";
try
{
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.Default);
resultModel = reader.ReadToEnd();
reader.Close();
}
catch (Exception ex)
{
return null;//连接服务器失败
}
return resultModel;
}
}
查看一下你这两类的命名空间是不是一样的,再看下是否引用
前面加上命名空间:new fuckspace.Test1()。以老夫掐指一算,你的命名空间可能也叫Test1,此处编译器以为你写的是命名空间的名称,而不是类名。
AAA这个类。。要public
不对,是Test1这个类。。。