【问题标题】:System.ComponentModel.Win32Exception. The system cannot the specified file. Review Stack TraceSystem.ComponentModel.Win32Exception。系统无法指定文件。查看堆栈跟踪
【发布时间】:2017-06-20 09:46:39
【问题描述】:

在浏览器中运行程序后,源错误信息说ViewBag.userdetails = db.FirstTables.ToList();

我收到以下错误消息:

系统找不到指定的文件

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

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

Line 15:         public ActionResult Index()
Line 16:         {
Line 17:             ViewBag.userdetails = db.FirstTables.ToList();
Line 18:             return View();
Line 19:         }
    ***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; }
             }        
        }

【问题讨论】:

  • 我猜 ViewBag 代码不是错误的来源。如果您评论该行会发生什么?您还可以添加堆栈跟踪吗?
  • 你的连接字符串正确吗?
  • 你能粘贴堆栈跟踪吗?
  • 嘿,我对此很陌生。在哪里可以找到堆栈跟踪?
  • @PankajKapare。我按照你说的做了,应用程序工作正常,但这让我的应用程序完全没用。不幸的是,它只是加载了一个基本网页。

标签: c# .net linq model-view-controller


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多