C# System.ComponentModel.Win32异常。系统无法访问指定的文件。查看堆栈跟踪

C# System.ComponentModel.Win32异常。系统无法访问指定的文件。查看堆栈跟踪,c#,.net,linq,model-view-controller,C#,.net,Linq,Model View Controller,在浏览器中运行程序后,源错误消息指出ViewBag.userdetails=db.FirstTables.ToList()中存在问题 我收到以下错误消息: 系统找不到指定的文件 描述:在执行过程中发生未处理的异常 当前的web请求。请查看堆栈跟踪以了解更多信息 有关错误的信息及其在代码中的来源 异常详细信息:System.ComponentModel.Win32异常:系统 找不到指定的文件 源错误: Line 15: public ActionResult Index() Lin

在浏览器中运行程序后,源错误消息指出ViewBag.userdetails=db.FirstTables.ToList()中存在问题

我收到以下错误消息:

系统找不到指定的文件

描述:在执行过程中发生未处理的异常 当前的web请求。请查看堆栈跟踪以了解更多信息 有关错误的信息及其在代码中的来源

异常详细信息:System.ComponentModel.Win32异常:系统 找不到指定的文件 源错误:

Line 15:         public ActionResult Index()
Line 16:         {
Line 17:             ViewBag.userdetails = db.FirstTables.ToList();
Line 18:             return View();
Line 19:         }
***代码:
财务总监:**
使用制度;
使用System.Collections.Generic;
使用System.Linq;
使用System.Web;
使用System.Web.Mvc;
使用System.Data.Entity;
命名空间MovingApplication.Controller
{
公共类HomeController:控制器
{
MoveDBEntities db=新的MoveDBEntities();
[HttpGet]
公共行动结果索引()
{
ViewBag.userdetails=db.FirstTables.ToList();
返回视图();
}
[HttpPost]
公共操作结果索引(字符串前缀)
{
var tempstring=(从db.FirstTables中的N开始)
其中N.name.StartsWith(前缀)
选择new{N.name}).ToList();
List obj=新列表();
foreach(tempstring中的变量项)
{
添加(新的自动完成(){name=item.name});
}
返回Json(obj,JsonRequestBehavior.AllowGet);
}
public ActionResult MoveData(字符串a)
{
SecondTable t2=新的SecondTable();
t2.name=a;
db.SecondTables.Add(t2);
db.SaveChanges();
ViewBag.userdetails2=db.SecondTables.ToList();
List fundList=db.SecondTables.ToList();
ViewBag.userdetails3=资金列表;
返回部分视图(“部分视图”,t2);
//返回Json(data2,JsonRequestBehavior.AllowGet);
}
公共类自动完成
{
公共字符串名称{get;set;}
}
}
}
***型号:***
使用制度;
使用System.Collections.Generic;
使用System.Linq;
使用System.Web;
名称空间MovingApplication.Models
{
公共班级1
{
公共int id{get;set;}
公共字符串名称{get;set;}
}        
}

验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。验证SQL Server Express是否已正确安装,以及本地数据库运行时功能是否已启用`


请检查您的连接字符串,它可能无效。这可能对你有帮助。如果sql server内存不足,释放内存也可能有效。

我猜ViewBag代码不是错误源。如果你评论那句话会怎么样?另外,你能添加堆栈跟踪吗?你的连接字符串正确吗?你能粘贴堆栈跟踪吗?嘿,我对这个很陌生。我在哪里可以找到堆栈跟踪?@PankajKapare。我照你说的做了,应用程序运行正常,但这使我的应用程序完全无用。不幸的是,它只是加载了一个基本的网页。
    ***Code:
    Controller:*** 

        using System;
        using System.Collections.Generic;
        using System.Linq;
        using System.Web;
        using System.Web.Mvc;
        using System.Data.Entity;

        namespace MovingApplication.Controllers
        {
            public class HomeController : Controller
            {
                MoveDBEntities db = new MoveDBEntities();

                [HttpGet]
                public ActionResult Index()
                {
                    ViewBag.userdetails = db.FirstTables.ToList();
                    return View();
                }

                [HttpPost]
                public ActionResult Index(string Prefix)
                {

                    var tempstring = (from N in db.FirstTables
                                      where N.name.StartsWith(Prefix)
                                      select new { N.name }).ToList();

                    List<Autocomplete> obj = new List<Autocomplete>();
                    foreach (var item in tempstring)
                    {
                        obj.Add(new Autocomplete() { name = item.name });
                    }
                    return Json(obj, JsonRequestBehavior.AllowGet);
                }


                public ActionResult MoveData(string a)
                {
                    SecondTable t2 = new SecondTable();
                    t2.name = a;
                    db.SecondTables.Add(t2);
                    db.SaveChanges();
                    ViewBag.userdetails2 = db.SecondTables.ToList();
                    List<SecondTable> fundList = db.SecondTables.ToList();
                    ViewBag.userdetails3 = fundList;
                    return PartialView("_PartialViewX",t2);
                  //return Json(data2,JsonRequestBehavior.AllowGet);

                }

                public class Autocomplete
                {
                    public string name { get; set; }
                }
            }
}


    ***Model:***
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;

        namespace MovingApplication.Models
        {
            public class Class1
            {
                public int id { get; set; }
                public string name { get; set; }
             }        
        }