[Win32Exception(0x80004005):系统找不到指定的文件] [英] [Win32Exception (0x80004005): The system cannot find the file specified]

查看:6165
本文介绍了[Win32Exception(0x80004005):系统找不到指定的文件]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我使用C#,实体框架,MVC和我做代码优先。



现在,当我尝试在我的数据库中读出一些东西时,我放在标题中的错误显示出来。我不知道要找什么。
我抬头看谷歌,但我没有得到一个答案...



我尝试提供你可能需要知道的所有代码: / p>

  public class上下文:DbContext 
{
public DbSet< Categorie>类别{get; set;}

public Context():base(Witze_DB)
{
}
}

public class HomeController:Controller
{
private Context db;

public HomeController(Context db)
{
this.db = db;
}

public ActionResult Index()
{
var allCats = db.Categories;
return View(allCats);
}
}

这是索引.cshtml 文件:

  @model IEnumerable< Witze.Categorie> 

@ {
ViewBag.Title =索引;
}

< h2>索引< / h2>

< p>
@ Html.ActionLink(创建新,创建)
< / p>
< table>
< tr>
< th>
@ Html.DisplayNameFor(model => model.Name)
< / th>
< th>< / th>
< / tr>

@foreach(模型中的var item){
< tr>
< td>
@ Html.DisplayFor(modelItem => item.Name)
< / td>
< td>
@ Html.ActionLink(编辑,编辑,新的{id = item.CategorieId})|
@ Html.ActionLink(Details,Details,new {id = item.CategorieId})|
@ Html.ActionLink(Delete,Delete,new {id = item.CategorieId})
< / td>
< / tr>
}

< / table>

这是我回来的:(这会更长,如果它帮助你,我会发布其余的,它只是更多的 System.Data.SqlClient ...)

 '/'应用程序中的服务器错误。 
---------------------------------------------- ----------------------------------


系统找不到指定的文件
说明:在执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误的更多信息及其在代码中的起始位置。

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

源错误:





第18行:< / tr>
第19行:
第20行:@foreach(模型中的var item){
第21行:< tr>
第22行:< td>

源文件:c:\Users\a80815067.EISLAB\Documents\Visual Studio 2012\Projects\Witze_Logik\Witze_Web\Views\Home\Index.cshtml行:20

堆栈跟踪:





[Win32Exception(0x80004005):系统找不到指定的文件]

[SqlException(0x80131904))建立与SQL Server的连接时发生与网络相关或实例特定的错误。服务器未找到或无法访问。验证实例名称是否正确,并将SQL Server配置为允许远程连接。 (提供程序:SQL网络接口,错误:52 - 无法找到本地数据库运行时安装。验证SQL Server Express是否已正确安装,并且已启用本地数据库运行时功能。)]
System.Data.SqlClient。 SqlInternalConnection.OnError(SqlException异常,Boolean breakConnection,Action`1 wrapCloseInAction)+5295887
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj,Boolean callerHasConnectionLock,Boolean asyncClose)+242

如果您需要任何其他信息,请问。

解决方案<看看stacktrace,你有以下错误:


服务器未找到或无法访问。验证
实例名称是否正确,并且SQL Server配置为允许
远程连接。 (提供者:SQL网络接口,错误:52 -
无法找到本地数据库运行时安装验证
SQL Server Express是否已正确安装,并且本地数据库
运行时功能已启用。


很可能,您的连接字符串无效。


I'm working on a joke web application.

I work with C#, Entity Framework, MVC and I do code-first.

Now when i try to read out something in my DB, the error I put in the title shows up. And I have no idea what to look for. I looked up Google but I didn't quite get an answer...

I try to provide all the code that you could need to know:

public class Context : DbContext
{
    public DbSet<Categorie> Categories {get;set;}

    public Context() : base("Witze_DB")
    {
    }
}

public class HomeController : Controller
{
    private Context db;

    public HomeController(Context db)
    {
        this.db = db;
    }

    public ActionResult Index()
    {
        var allCats = db.Categories;
        return View(allCats);
    }
}

And this is the Index.cshtml file:

@model IEnumerable<Witze.Categorie>

@{
ViewBag.Title = "Index";
}

<h2>Index</h2>

<p>
@Html.ActionLink("Create New", "Create")
</p>
<table>
<tr>
    <th>
        @Html.DisplayNameFor(model => model.Name)
    </th>
    <th></th>
</tr>

@foreach (var item in Model) {
<tr>
    <td>
        @Html.DisplayFor(modelItem => item.Name)
    </td>
    <td>
        @Html.ActionLink("Edit", "Edit", new { id=item.CategorieId }) |
        @Html.ActionLink("Details", "Details", new { id=item.CategorieId }) |
        @Html.ActionLink("Delete", "Delete", new { id=item.CategorieId })
    </td>
</tr>
}

</table>

This is what I get back: (it would be much longer, if it does help you I will post the rest as well, it's just more System.Data.SqlClient...)

Server Error in '/' Application.
--------------------------------------------------------------------------------


 The system cannot find the file specified 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ComponentModel.Win32Exception: The system cannot find the file specified

Source Error: 





    Line 18:     </tr>
    Line 19: 
    Line 20: @foreach (var item in Model) {
    Line 21:     <tr>
    Line 22:         <td> 

Source File: c:\Users\a80815067.EISLAB\Documents\Visual Studio 2012\Projects\Witze_Logik\Witze_Web\Views\Home\Index.cshtml    Line: 20 

Stack Trace: 





[Win32Exception (0x80004005): The system cannot find the file specified]

[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)]
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5295887
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +242

If you need any other information just ask.

解决方案

Have a look at the stacktrace, you have the following error:

The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.

Most probably, your connection string is invalid.

这篇关于[Win32Exception(0x80004005):系统找不到指定的文件]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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