Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 564
WTFisOssi Avatar asked Feb 12 '14 14:02

WTFisOssi


People also ask

What is Win32Exception 0x80004005?

Win32Exception (0x80004005): The system cannot find the path specified. Developer Network.

How do I fix the system Cannot find the file specified?

Run CHKDSK Command to Fix "System Cannot Find File Specified" Device. Right-click the Start button, type cmd in the Search, and select Command Prompt (Admin). Type chkdsk x: /f /r (x represents your target drive) into the Command Prompt window and press Enter Wait while chkdsk tries to repair the corrupted file systems ...

Was Error 2 The system Cannot find the file specified?

Code: 2. The system cannot find the file specified. This error usually pops up when Book Collector doesn't have enough rights to access certain files, however it can also happen if you use some kind of data sync program such as Google Drive, OneDrive, iDrive or something similar.


1 Answers

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.

like image 109
ken2k Avatar answered Oct 11 '22 12:10

ken2k