gpt4 book ai didi

c# - 该进程无法访问文件 '.mdf',因为该文件正在被另一个进程使用

转载 作者:行者123 更新时间:2023-12-03 02:42:44 25 4
gpt4 key购买 nike

我将 ASP.NET 动态数据 Web 模板与 SQL Server 2008 数据库结合使用,当我尝试在 App_Data 中添加 .mdf 文件时,我得到了

The file cannot be opened because it is being used by another process. Please close all applications that might access this file and try again

我尝试寻找解决方案,但它非常不同

Hi Ken, this is because you are trying to add your DB to the project (i.e. copy it there) not connect to it, to connect add a Entity Framework data model and then select your Data base and all should go well.

If you actually want to have the DB in the App_Data folder then you will need:

To have SQL Server Express installed locally and on your web server. Temporarily stop your SQL Server so that the DB is accessible then copy it to the App_Data folder.

或者

  1. Go to SQL Server Configuration Tools and stop the SqlserverExpress Service.

  2. In Solution Explorer a Right click on project add existing Item ., Go to Program files and search for you required .mdf file in it add it to Project.

  3. Goto SQL Server Configuration tools start the Sqlexpress Service.

  4. Run Your solution.

如何解决我的问题?

最佳答案

查找正在使用该文件的进程的最简单方法是:

  1. 运行“resmon”。 (使用Windows搜索来查找该程序)
  2. 在第二个选项卡内的搜索栏中输入名称 + 扩展名
  3. 结果将是正在使用该文件的进程。

(是的,我知道这是一个老问题)

关于c# - 该进程无法访问文件 '.mdf',因为该文件正在被另一个进程使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13786362/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com