How to resolve "error code is 0x80070001"? - c#

I get the following error with the following stack trace. How do I resolve this?
error code is 0x80070001
Stack trace
[Type] Error | [Source] AccountsServices:An error occurred while communicating with the remote host. The error code is 0x80070001. | [Category] None | [Event] 0 | [User] | [Computer] VM2014.conduit.local | [Description] Message was not found: 0
_Duration=207593.75
Message:An error occurred while communicating with the remote host. The error code is 0x80070001.
StackTrace: at System.Web.Hosting.IIS7WorkerRequest.RaiseCommunicationError(Int32 result, Boolean throwOnDisconnect)
at System.Web.Hosting.IIS7WorkerRequest.ReadEntityCoreSync(Byte[] buffer, Int32 offset, Int32 size)
at System.Web.HttpRequest.GetEntireRawContent()
at System.Web.HttpRequest.FillInFormCollection()
at System.Web.HttpRequest.get_Form()
at System.Web.HttpRequest.FillInParamsCollection()
at System.Web.HttpRequest.GetParams()
at BrandToolbar.Web.Profile.ConduitProfileModule.UpdateVar() in d:\conduit\RnD\Server\Infrastructure\Providers\Web\Profile\Dev\ConduitProfileModule.cs:line 119
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

This isn't an issue with your application code, but probably your environment configuration. Are you using VMs?
You may or may not find this forum post helpful: http://social.technet.microsoft.com/Forums/en-US/winserverhyperv/thread/698e2b2b-af59-4848-b041-4fbb11c5bb6b

Related

"System.ComponentModel.Win32Exception (0x80090308): The token supplied to the function is invalid" when TLS13 is enabled

After adding the below registry key to enable TLS1.3 on Windows Server 2022
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Client]
"DisabledByDefault"=dword:00000000
"Enabled"=dword:00000001
The .NET Client application throws the below exception
System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception.
---> System.ComponentModel.Win32Exception (0x80090308): The token supplied to the function is invalid
--- End of inner exception stack trace ---
at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)
at System.Net.Security.SslStream.AuthenticateAsClient(SslClientAuthenticationOptions sslClientAuthenticationOptions)
at System.Net.Security.SslStream.AuthenticateAsClient(String targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation)
Is there anything i am missing? In the .NET Client application i had set the protocol version to TLS13.
Thanks in advance.
Try the below before you call the server if server is also on windows 2022+
Otherwise it will not work if server is not 2022+
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls13

Connection Refused - Redis for Data Protection Keys in ASP.Net Core 2.1

I'm going through this article from Microsoft:
https://learn.microsoft.com/en-us/aspnet/core/security/data-protection/implementation/key-storage-providers?view=aspnetcore-2.1
I am trying to do the following:
services.AddDataProtection()
.PersistKeysToRedis(ConnectionMultiplexer.Connect("localhost"));
Error Stack:
app | Unhandled Exception: System.AggregateException: One or more errors occurred. (Connection refused) ---> System.Net.Sockets.SocketException: Connection refused
app | at System.Net.Sockets.Socket.BeginConnectEx(EndPoint remoteEP, Boolean flowContext, AsyncCallback callback, Object state)
app | at System.Net.Sockets.Socket.UnsafeBeginConnect(EndPoint remoteEP, AsyncCallback callback, Object state, Boolean flowContext)
app | at System.Net.Sockets.Socket.PostOneBeginConnect(MultipleAddressConnectAsyncResult context)
app | --- End of stack trace from previous location where exception was thrown ---
app | at System.Net.Sockets.Socket.DoMultipleAddressConnectCallback(Object result, MultipleAddressConnectAsyncResult context)
app | at System.Net.Sockets.Socket.DoDnsCallback(IAsyncResult result, MultipleAddressConnectAsyncResult context)
app | at System.Net.Sockets.Socket.BeginConnect(String host, Int32 port, AsyncCallback requestCallback, Object state)
app | at System.Net.Sockets.Socket.ConnectAsync(String host, Int32 port)
app | at System.Net.Sockets.SocketTaskExtensions.ConnectAsync(Socket socket, String host, Int32 port)
app | at StackExchange.Redis.SocketManager.BeginConnect(EndPoint endpoint, ISocketCallback callback, ConnectionMultiplexer multiplexer, TextWriter log) in c:\code\StackExchange.Redis\StackExchange.Redis\StackExchange\Redis\SocketManager.cs:line 194
I am using Docker:
redis:
image: redis:alpine
container_name: redis
ports:
- "6379:6379"
Any ideas?
You need to reference the container and port
services.AddDataProtection()
.PersistKeysToRedis(ConnectionMultiplexer.Connect("redis:6379"));
I also added abortConnect=false" to configuration
REDIS_CONNECTION_STRING = "redis:6379,abortConnect=false"
var redis = ConnectionMultiplexer.Connect(Environment.GetEnvironmentVariable("REDIS_CONNECTION_STRING"));
services.AddDataProtection().PersistKeysToRedis(redis, "DataProtection-Keys");

System.NullReferenceException in System.Data.RBTree`1.Minimum(Int32 x_id)

I am occationally getting a null reference exception when running my bitcoin node (written in C# .NET 4.5). I have been trying various apporaches, but it keeps coming up, sometimes after a few hours, sometimes after the server has been running uninterrupted for days. I am unable to provoke the issue (cannot reproduce), and I cannot see the source of the .NET implementation of the red-black-tree either. It seems it could be an internal .NET bug related to clearing a dataset. I have an exception trace here. I would appreciate any feedback on how to either correct the issue or work around it, in case anyone has had the same odd experience.
HResult: -2146233088, 0x80131500
Exception Source:
Exception Origin:
Exception Stack:
Exception Type: Slf.Cs.SlfInternalErrorException
Exception Message: SelectData with SELECT statement: "SELECT * FROM [dbo].[BlockHeaders] WHERE BlockHash = #EqualToValue" failed.
SlfException Info:
HResult: -2146233088, 0x80131500
Exception Source: Slf.Cs
Exception Origin: Int32 SelectData(System.Data.SqlClient.SqlConnection, Int32, System.Data.DataTable, System.String, System.Data.SqlClient.SqlParameter[])
Exception Stack: at Slf.Cs.SlfSqlUtilities.SelectData(SqlConnection connection, Int32 timeoutSeconds, DataTable dataTable, String selectStatement, SqlParameter[] parameters) in C:\Data Files\Development Projects\iProtus\Frameworks\Slf.Cs\System\Basics\SlfUtilities.cs:line 1231
at Slf.Cs.Data.SlfSqlTable`1.Select(String columnName, Object equalToValue, Int32 maxCount, String orderByStatement) in C:\Data Files\Development Projects\iProtus\Frameworks\Slf.Cs\System\Database\SqlServer\SlfSqlDatabase.cs:line 950
at Slf.Cs.CryptCoin.BlockchainDB.GetDbBlockHeadersByBlockHash(Byte[] headerHash) in C:\Data Files\Development Projects\iProtus\Frameworks\Slf.Cs.CryptCoin\Basics\BlockchainDB.cs:line 212
at Slf.Cs.CryptCoin.BlockchainDB.GetBlockHeight(SlfByte32 blockHash) in C:\Data Files\Development Projects\iProtus\Frameworks\Slf.Cs.CryptCoin\Basics\BlockchainDB.cs:line 856
at Slf.Cs.CryptCoin.BitcoinStore.GetBlockHeight(SlfByte32 hash) in C:\Data Files\Development Projects\iProtus\Frameworks\Slf.Cs.CryptCoin\Basics\BitcoinStore.cs:line 597
at Slf.Cs.CryptCoin.BitcoinPeer.ExecuteGetHeadersCommand(BitcoinMessage message) in C:\Data Files\Development Projects\iProtus\Frameworks\Slf.Cs.CryptCoin\Network\BitcoinPeer.cs:line 829
at Slf.Cs.CryptCoin.BitcoinPeer.ExecuteCommand(BitcoinMessage message) in C:\Data Files\Development Projects\iProtus\Frameworks\Slf.Cs.CryptCoin\Network\BitcoinPeer.cs:line 1223
at Slf.Cs.CryptCoin.BitcoinPeer.ProcessNextCommand() in C:\Data Files\Development Projects\iProtus\Frameworks\Slf.Cs.CryptCoin\Network\BitcoinPeer.cs:line 1591
at Slf.Cs.CryptCoin.BitcoinPeer.Run(Object userContext) in C:\Data Files\Development Projects\iProtus\Frameworks\Slf.Cs.CryptCoin\Network\BitcoinPeer.cs:line 1740
at Slf.Cs.CryptCoin.BitcoinNode.Peer(PeerContext context) in C:\Data Files\Development Projects\iProtus\Frameworks\Slf.Cs.CryptCoin\Network\BitcoinNode.cs:line 857
at Slf.Cs.SlfPeerToPeerNode.InternalPeerThread(PeerContext context) in C:\Data Files\Development Projects\iProtus\Frameworks\Slf.Cs\System\Network\SlfPeerToPeerNode.cs:line 1977
Exception Type: System.NullReferenceException
Exception Message: Object reference not set to an instance of an object.
HResult: -2147467261, 0x80004003
Exception Source: System.Data
Exception Origin: Int32 Minimum(Int32)
Exception Stack: at System.Data.RBTree`1.Minimum(Int32 x_id)
at System.Data.RBTree`1.Successor(Int32& nodeId, Int32& mainTreeNodeId)
at System.Data.RBTree`1.RBTreeEnumerator.MoveNext()
at System.Data.Index.InitRecords(IFilter filter)
at System.Data.Index.Reset()
at System.Data.DataTable.ResetInternalIndexes(DataColumn column)
at System.Data.DataTable.Clear(Boolean clearAll)
at System.Data.DataTable.Clear()
at Slf.Cs.SlfSqlUtilities.FillDataTable(SqlDataAdapter adapter, DataTable dataTable) in C:\Data Files\Development Projects\iProtus\Frameworks\Slf.Cs\System\Basics\SlfUtilities.cs:line 1299
at Slf.Cs.SlfSqlUtilities.SelectData(SqlConnection connection, Int32 timeoutSeconds, DataTable dataTable, String selectStatement, SqlParameter[] parameters) in C:\Data Files\Development Projects\iProtus\Frameworks\Slf.Cs\System\Basics\SlfUtilities.cs:line 1222
--Edit, due to nature of initial comments--
Look at the innermost exception trace. This is a call to the standard DataTable.Clear() method, that is supposed to remove all from a DataTable. The rest doesn't really matter. In hindsight, I should have just posted that innermost exception.
Furthermore, I do not see the need to provide sample code, as one requested, since it obviously is internal to .NET. Most likely it is concurrency related, which I tried circumvent by wrapping all my DataTable.Clear() calls in a lock on a static object, and it still happens. The fact that it happens rarely and with random intervals is another good indication that concurrency is the issue. However, trying everything, I finally gave up and posted here, hoping someone else has this issue solved :)

An error occurred while connecting to Firefox ---> System.IO.IOException: The directory is not empty

I am working with selenium the last months. I use VS 2013 C#. Most of the time i am using webdriver.dll (2.39.0.0) for firefox (31.0.0.5310), because my testautomation (coded ui tests)
ran pretty stable with it. but now i get randomly this error:
> OpenQA.Selenium.WebDriverException: An error occurred while connecting to Firefox ---> System.IO.IOException: The directory is not empty.
Result StackTrace:
at System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive, Boolean throwOnTopLevelDirectoryNotFound)
at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive, Boolean checkHost)
at OpenQA.Selenium.Firefox.FirefoxExtension.Install(String profileDir) in c:\Projects\WebDriver\trunk\dotnet\src\webdriver\Firefox\FirefoxExtension.cs:line 106
at OpenQA.Selenium.Firefox.FirefoxProfile.InstallExtensions() in c:\Projects\WebDriver\trunk\dotnet\src\webdriver\Firefox\FirefoxProfile.cs:line 357
at OpenQA.Selenium.Firefox.FirefoxProfile.WriteToDisk() in c:\Projects\WebDriver\trunk\dotnet\src\webdriver\Firefox\FirefoxProfile.cs:line 254
at OpenQA.Selenium.Firefox.Internal.ExtensionConnection.Start() in c:\Projects\WebDriver\trunk\dotnet\src\webdriver\Firefox\Internal\ExtensionConnection.cs:line 90
at OpenQA.Selenium.Firefox.FirefoxDriver.StartClient() in c:\Projects\WebDriver\trunk\dotnet\src\webdriver\Firefox\FirefoxDriver.cs:line 225
--- End of inner exception stack trace ---
at OpenQA.Selenium.Firefox.FirefoxDriver.StartClient() in c:\Projects\WebDriver\trunk\dotnet\src\webdriver\Firefox\FirefoxDriver.cs:line 231
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities) in c:\Projects\WebDriver\trunk\dotnet\src\webdriver\Remote\RemoteWebDriver.cs:line 88
at Testcase1.UIMap.BrowserSettingsFF() in c:***************\UIMap.cs:line 609
at Testcase1.UIMap.InitDriver() in c:***************\UIMap.cs:line 678
I run it on 2 devices working with TFS. On one device it happens much more often.
I could not figure out the problem by now. Has anyone the same problem?

"Padding is invalid and cannot be removed." error with a twist

I'm getting the following error in our QA environment but only through the IIS7 reverse proxy. If I hit the application server directly it works fine. In our DEV environment it works fine through the proxy or directly.
I'm not really sure where to go with this, any ideas?
Server Error in '/' Application.
Padding is invalid and cannot be removed.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[CryptographicException: Padding is invalid and cannot be removed.]
System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast) +2910
System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount) +286
System.Security.Cryptography.CryptoStream.FlushFinalBlock() +51
System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, IVType ivType, Boolean useValidationSymAlgo) +318
System.Web.UI.Page.DecryptStringWithIV(String s, IVType ivType) +115
System.Web.Handlers.AssemblyResourceLoader.System.Web.IHttpHandler.ProcessRequest(HttpContext context) +140
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +599
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171
Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4927
If this is happens on page with out post back then probably your proxy is convertting the url in lowercase chars and break the code.
I have one more bigger answer here with a trick to log the error and see whats really get on your page:
CryptographicException: Padding is invalid and cannot be removed and Validation of viewstate MAC failed

Categories

Resources