为什么我得到(你是否缺少程序集引用)错误 [英] Why I am getting (are you missing assembly references) error

查看:86
本文介绍了为什么我得到(你是否缺少程序集引用)错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用System; 
使用System.Collections.Generic;
使用System.Linq;
使用System.Web;
使用System.Web.Mvc;
使用MVC1.Models;
命名空间MVC1.Controllers
{
公共类客户
{
public string customername {get;组; }
公共字符串地址{get;组; }
公共字符串电话{get;组; }
public override string ToString()
{
return this.customername ++ this.address + this.phone;
}
}
公共级员工
{
公共字符串名字{get;组; }
公共字符串LastName {get;组; }
public int budget {get;组; }
}

公共类TestController:Controller
{
public ActionResult GetView()
{
employee emp = new employee();
emp.Firstname =KARAN;
emp.LastName =Kumar;
emp.budget = 30000;
ViewData [employee] = emp;
返回查看(查看);
}
公共客户Getcustomer()
{
customer cus = new customer();
cus.customername =AMAN;
cus.address =来自斯里兰卡;
cus.phone =456478546;
返回cus;
}
}
}





我尝试了什么:



i尝试在.net程序集参考中搜索System.Configuration但也可以使用此参考



在代码部分模型中出错

使用MVC1.Models; 

解决方案

< blockquote>可能是因为你没有对包含该命名空间的项目/ .DLL的引用设置



或者项目的目标是两个不同的,并且引用不兼容, .NET Framework的版本。



或者项目是使用不同的目标平台,x64或AnyCPU在一个和x86在另一个上构建的。


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MVC1.Models;
namespace MVC1.Controllers
{
    public class customer
    {
        public string customername { get; set; }
        public string address { get; set; }
        public string phone { get; set; }
        public override string ToString()
        {
            return this.customername + "" + this.address + this.phone;
        }  
    }
    public  class employee
    {
        public string Firstname { get; set; }
        public string LastName { get; set; }
        public int budget { get; set; }
    }
    
    public class TestController : Controller
    {
        public ActionResult GetView()
        {
            employee emp = new employee();
            emp.Firstname = "KARAN";
            emp.LastName = "Kumar";
            emp.budget = 30000;
            ViewData["employee"] = emp;
            return View("View");
        }
        public customer Getcustomer()
        {
            customer cus = new customer();
            cus.customername = "AMAN";
            cus.address = "   From Srilanka ";
            cus.phone = " 456478546";
            return cus;
        }
	}
}



What I have tried:

i tried searching for System.Configuration in the .net assemblies references also but this reference is also available

Getting error in this portion of code Model

using MVC1.Models;

解决方案

Probably because you don't have a reference set to the project/.DLL that contains that namespace

OR the projects are targeting two different, and reference incompatible, versions of the .NET Framework.

OR the projects are built using differing Target Platforms, x64 or AnyCPU on one and x86 on the other.


这篇关于为什么我得到(你是否缺少程序集引用)错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆