加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

.net – 为什么,当我在WCF服务中模拟时,当我尝试运行LINQ to SQL

发布时间:2020-12-12 06:35:13 所属栏目:MsSql教程 来源:网络整理
导读:我有一个WCF服务,托管在IIS 7.0中,需要运行数据库查询.为了获得正确的权限,我在服务中模仿如下: 码 [OperationBehavior(Impersonation = ImpersonationOption.Allowed)]public void MyOperation(int arg) 组态 behavior name="ReceivingServiceBehavior" !--
我有一个WCF服务,托管在IIS 7.0中,需要运行数据库查询.为了获得正确的权限,我在服务中模仿如下:

[OperationBehavior(Impersonation = ImpersonationOption.Allowed)]
public void MyOperation(int arg)

组态

<behavior name="ReceivingServiceBehavior">
    <!-- Other behaviors -->
    <serviceAuthorization impersonateCallerForAllOperations="true" />
</behavior>

当我尝试连接并运行我的查询时,我得到以下内容:

Exception - System.IO.FileLoadException: Could not load file or
assembly 'System.Transactions,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089' or one of its dependencies. Either a
required impersonation level was not provided,or the provided
impersonation level is invalid. (Exception from HRESULT: 0x80070542)

File name: 'System.Transactions,PublicKeyToken=b77a5c561934e089' ---> System.Runtime.InteropServices.COMException (0x80070542): Either a required impersonation level was not provided,or the provided impersonation level is invalid. (Exception from HRESULT: 0x80070542)
   at System.Data.Linq.SqlClient.SqlConnectionManager.UseConnection(IConnectionUser user)
   at System.Data.Linq.SqlClient.SqlProvider.get_IsSqlCe()
   at System.Data.Linq.SqlClient.SqlProvider.InitializeProviderMode()
   at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
   at System.Data.Linq.DataQuery`1.System.Collections.Generic.IEnumerable.GetEnumerator()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Fourth.GHS.MessageRelay.RegistrationDBStorage.FindRegistration(SystemKey key)

解决方法

如果希望将SQL查询作为模拟标识执行,则实际上可能需要启用对SQL Server的委派.查看这篇文章了解更多信息:

http://msdn.microsoft.com/en-us/library/ms730088.aspx

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读