首页新闻找找看学习计划

未能找到类型或命名空间名称“Test1”(是否缺少 using 指令或程序集引用?)

0
悬赏园豆:20 [已解决问题] 解决于 2018-11-22 09:31

Test1是个我自己建的类、我需要用到里面的AAA方法 但是一直抱着个错误

素雅淡生丶的主页 素雅淡生丶 | 初学一级 | 园豆:47
提问于:2018-11-20 16:33
< >
分享
最佳答案
0

看你Test1类所在命名空间,最好发一下代码

收获园豆:20
秋壶冰月 | 大侠五级 |园豆:5450 | 2018-11-20 20:32

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;
}
}

素雅淡生丶 | 园豆:47 (初学一级) | 2018-11-21 08:12

@素雅淡生丶: new Test1() 引入OThinker.H3.Portal.Sheets.DefaultEngine这个命名空间,或者在Test1前面加上OThinker.H3.Portal.Sheets.DefaultEngine这个命名空间

秋壶冰月 | 园豆:5450 (大侠五级) | 2018-11-21 14:52
其他回答(4)
0

你看看你那个类里面的命名是Test1吗,或者你引用一下放Test1的那个层。

徒然喜欢你 | 园豆:1601 (小虾三级) | 2018-11-20 16:37

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;
}
}

支持(0) 反对(0) 素雅淡生丶 | 园豆:47 (初学一级) | 2018-11-21 08:13
0

查看一下你这两类的命名空间是不是一样的,再看下是否引用

画笔灬 | 园豆:900 (小虾三级) | 2018-11-20 16:43
0

前面加上命名空间:new fuckspace.Test1()。以老夫掐指一算,你的命名空间可能也叫Test1,此处编译器以为你写的是命名空间的名称,而不是类名。

会长 | 园豆:6782 (大侠五级) | 2018-11-20 16:43
0

AAA这个类。。要public

rqx | 园豆:468 (菜鸟二级) | 2018-11-20 18:53

不对,是Test1这个类。。。

支持(0) 反对(0) rqx | 园豆:468 (菜鸟二级) | 2018-11-20 18:53
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册