【发布时间】:2013-10-16 22:06:13
【问题描述】:
我已经为此工作了一段时间,但我不知道该怎么做。所以这就是问题所在。
我有一个 Azure Web 服务,可以在本地完美运行。它应该连接到 Azure SQL 数据库(我使用相同的 ConnectionString 进行调试和天蓝色.. 所以它应该是正确的)
使用 IntelliTrace,我发现以下错误:
Requested registry access is not allowed.
System.IO.FileNotFoundException Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=Neutral....
System.Data.Entity.Core.ProviderIncompatibleException
System.Data.SqlClient.SqlException A network-related or instance-specific error occured while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct... (This about 50 times)
System.Threading.WaitHandleCannotBeOpenedException No handle of the given name exists.
System.Security.SecurityException Requested registry access is not allowed
Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironmentException error
System.Threading.WaitHandleCannotBeOpenedException No handle of the given name exists.
(异常堆栈,顶部最新,底部最旧)
在我的 web.config 中,我像这样设置 EF 和 ConnectionString:
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="EntityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework" requirePermission="false"/>
</configSections>
<connectionStrings>
<add name="DefaultConnection" connectionString="Server=SERVER.database.windows.net;Database=LeagueMetaDatabase;User ID=USER@ksew7pk8ad;Password=PW;Trusted_Connection=False;Encrypt=True;" providerName="System.Data.SqlClient"/>
</connectionStrings>
我还为 EF 程序集停用了“特定版本”并激活了“复制本地”。 我检查了服务器上服务的bin文件夹,dll在那里。
该服务使用了很多异步,但如前所述,它可以在本地运行。我还在服务器上安装了 .NET 4.5.1 以确保这不是问题
// 编辑 首先,感谢到目前为止的所有帮助!
我尝试缩小问题范围。重新构建孔项目并尝试找出不起作用的地方。似乎异步任务无法读取 Azure 服务器云上 Web.config 中的 ConnectionString。在模拟器中,它可以工作。我将 ConnectionString 硬编码到 Context 中,它就是这样工作的。
谁能告诉我是什么造成了这种行为以及如何将其放回 Web.config 中?
【问题讨论】:
-
如何部署到 Azure?如果您在 VS 中使用“发布”方法,那么您可能会检查是否设置了正确的连接字符串 - 我记得 Visual Studio 将连接字符串从开发替换为生产,您可以检查一下。此外,我不建议在 Azure 上使用任何不稳定的东西——我也遇到过很多问题(我看到你使用的是 EF 6)。
-
web.config 中的
标记中有什么?它引用了哪个 EF? -
我的服务的 web.config 中没有运行时标签
-
我正在使用 VS 2013 RC 发布,我检查了服务器上的 web.config,它没有更改连接字符串
-
标签: c# sql sql-server entity-framework azure