问题描述
我有一个在centOs上使用sql server的项目,它在Windows localhost和IIS上完美运行,但当我在centOs 7上部署项目并且我使用的是kestrel web服务器时,它给了我许多错误,我相信与用于授权我的项目的身份相关。
我没有知道它在说什么或者问题是什么。请帮助我。
PersonalDataProtector,第109行:
I have a project that is using sql server on centOs, its working perfectly on Windows localhost and IIS, but when I deploy the project on centOs 7 and I'm using kestrel web server, it gives me to many errors that I believe are related to the identity that is used for authorization of my project.
I have no idea what it is saying or what's the problem. Please help me.
PersonalDataProtector, Line 109 :
public string Unprotect(string data)
{
byte[] plainText;
// Take our string and convert it back to bytes.
var payload = Convert.FromBase64String(data);
var offset = 0;
// First we extract our key ID and then the appropriate key.
byte[] keyIdAsBytes = new byte[16];
Buffer.BlockCopy(payload, offset, keyIdAsBytes, 0, 16);
var keyIdAsGuid = new Guid(keyIdAsBytes); // Line 109
var keyId = keyIdAsGuid.ToString();
var masterKey = Key(keyId);
offset = 16;
PostPageAPiController ,第109行:
PostPageAPiController, Line 109:
var jobUser = await userManager.FindByIdAsync(job.UserId.ToString());
错误是:
在System.Collections.Generic.Dictionary`2.get_Item(TKey key)
,位于/root/xProjectFiles/DataProtection/PersonalDataProtector.cs:line 109中的X.Project.DataProtection.PersonalDataProtector.Unprotect(字符串数据)
at lambda_method(Closure,DbDataReader)在Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable`1.AsyncEnumerator.BufferlessMoveNext(DbContext _)中的
,布尔缓冲区,CancellationToken cancellationToken)
在Microsoft.Enti tyFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync [TState,TResult](TState状态,Func`4操作,Func`4 verifySucceeded,CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal。 AsyncQueryingEnumerable`1.AsyncEnumerator.MoveNext(CancellationToken cancellationToken)
在D:\\\\\的System.Linq.AsyncEnumerable.FirstOrDefault_ [TSource](IAsyncEnumerable`1 source,CancellationToken cancellationToken)中\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ .Query.Internal.AsyncLinqOperatorProvider.TaskResultAsyncEnumerable`1.Enumerator.MoveNext(CancellationToken cancellationToken)
在D:\\中的System.Linq.AsyncEnumerable.SelectEnumerableAsyncIterator`2.MoveNextCore(CancellationToken cancellationToken) \\1\\s\\Ix.NET\\Source\\\ System.Interactive.Async\\Select.cs:第106行
在D:\\\\\的System.Linq.AsyncEnumerable.AsyncIterator`1.MoveNext(CancellationToken cancellationToken)中\\ _ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ .Query.Internal.AsyncLinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext(CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteSingletonAsyncQuery [TResult](QueryContext queryContext,Func`2 compiledQuery, IDiagnosticsLogger`1 logger,Type contextType)
at X.Project.Controllers.PostPageApiController.getPrjPostInfos(Int32 id)in /root/xProjectFiles/Controllers/PostPageApiController.cs:line 109
我尝试了什么:
The errors are:
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at X.Project.DataProtection.PersonalDataProtector.Unprotect(String data) in /root/xProjectFiles/DataProtection/PersonalDataProtector.cs:line 109
at lambda_method(Closure , DbDataReader )
at Microsoft.EntityFrameworkCore.Storage.Internal.TypedRelationalValueBufferFactory.Create(DbDataReader dataReader)
at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable`1.AsyncEnumerator.BufferlessMoveNext(DbContext _, Boolean buffer, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable`1.AsyncEnumerator.MoveNext(CancellationToken cancellationToken)
at System.Linq.AsyncEnumerable.FirstOrDefault_[TSource](IAsyncEnumerable`1 source, CancellationToken cancellationToken) in D:\\a\\1\\s\\Ix.NET\\Source\\System.Interactive.Async\\First.cs:line 144
at Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.TaskResultAsyncEnumerable`1.Enumerator.MoveNext(CancellationToken cancellationToken)
at System.Linq.AsyncEnumerable.SelectEnumerableAsyncIterator`2.MoveNextCore(CancellationToken cancellationToken) in D:\\a\\1\\s\\Ix.NET\\Source\\System.Interactive.Async\\Select.cs:line 106
at System.Linq.AsyncEnumerable.AsyncIterator`1.MoveNext(CancellationToken cancellationToken) in D:\\a\\1\\s\\Ix.NET\\Source\\System.Interactive.Async\\AsyncIterator.cs:line 98
at Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext(CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteSingletonAsyncQuery[TResult](QueryContext queryContext, Func`2 compiledQuery, IDiagnosticsLogger`1 logger, Type contextType)
at X.Project.Controllers.PostPageApiController.getPrjPostInfos(Int32 id) in /root/xProjectFiles/Controllers/PostPageApiController.cs:line 109
What I have tried:
I have added these codes from other forums, but it didn't work.
<pre lang="c#">var manager = new ApplicationPartManager();
manager.ApplicationParts.Add(new AssemblyPart(typeof(Startup).Assembly));
services.AddSingleton(manager);
services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
.AddJsonOptions(
options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
);
推荐答案
这篇关于C# - system.collections.generic.dictionary`2.get_item(tkey key)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!