我有一个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)