Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# [Win32Exception(0x80004005):系统找不到指定的文件]_C#_Sql Server_Asp.net Mvc_Code First_Entity Framework 6 - Fatal编程技术网

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

C# [Win32Exception(0x80004005):系统找不到指定的文件],c#,sql-server,asp.net-mvc,code-first,entity-framework-6,C#,Sql Server,Asp.net Mvc,Code First,Entity Framework 6,我正在开发一个笑话网络应用程序 我使用C#、实体框架、MVC,我先编写代码 现在,当我试图读取数据库中的某些内容时,我在标题中输入的错误就会出现。我不知道该找什么。 我在谷歌上查了一下,但没有找到答案 我尝试提供您可能需要了解的所有代码: public class Context : DbContext { public DbSet<Categorie> Categories {get;set;} public Context() : base("Witze_DB"

我正在开发一个笑话网络应用程序

我使用C#、实体框架、MVC,我先编写代码

现在,当我试图读取数据库中的某些内容时,我在标题中输入的错误就会出现。我不知道该找什么。 我在谷歌上查了一下,但没有找到答案

我尝试提供您可能需要了解的所有代码:

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);
    }
}
这就是我得到的反馈:(它会更长,如果它确实对您有帮助,我也会发布其余的内容,它只是更
System.Data.SqlClient
。)

“/”应用程序中出现服务器错误。 -------------------------------------------------------------------------------- 系统找不到指定的文件 描述:执行当前web请求期间发生未处理的异常。请查看堆栈跟踪以了解有关错误的更多信息以及错误在代码中的起源。 异常详细信息:System.ComponentModel.Win32异常:系统找不到指定的文件 源错误: 第18行: 第19行: 第20行:@foreach(模型中的变量项){ 第21行: 第22行: 源文件:c:\Users\a80815067.EISLAB\Documents\Visual Studio 2012\Projects\Witze\u Logik\Witze\u Web\Views\Home\Index.cshtml行:20 堆栈跟踪: [Win32Exception(0x80004005):系统找不到指定的文件] [SqlException(0x80131904):建立与SQL Server的连接时发生网络相关或特定于实例的错误。找不到或无法访问该服务器。请验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。(提供程序:SQL网络接口,错误:52-找不到本地数据库运行时安装。请验证SQL Server Express是否已正确安装,以及本地数据库运行时功能是否已启用。)] System.Data.SqlClient.SqlInternalConnection.OneError(SqlException异常,布尔断开连接,操作'1 wrapCloseInAction)+5295887 System.Data.SqlClient.TdsParser.throweexception和warning(TdsParserStateObject stateObj,布尔调用者连接锁,布尔异步关闭)+242
如果您需要任何其他信息,请询问。

查看stacktrace,您有以下错误:

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


最有可能的是,您的连接字符串无效。

您是否阅读了整个异常?连接到SQL Server时似乎出现了问题。我们在2.0中看到了相同的问题,我认为它已经安装。问题似乎是它无法解析dotnet?在云构建中应该如何解决?谢谢=)似乎我不知道我对DB的整个连接在做什么。^^^现在我在正确的位置得到了正确的连接字符串=)
@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>
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