I am following a tutorial for Angular with ASP.NET Core WebAPI. When my angular server is not started, I can send request to the API through Postman no problem. As soon as I start my angular server, I get the following stack trace:
Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 1: 'cannot rollback - no transaction is active'.
at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader()
at Microsoft.Data.Sqlite.SqliteCommand.ExecuteNonQuery()
at Microsoft.Data.Sqlite.SqliteConnectionExtensions.ExecuteNonQuery(SqliteConnection connection,
String commandText, SqliteParameter[] parameters)
at Microsoft.Data.Sqlite.SqliteTransaction.RollbackInternal()
at Microsoft.Data.Sqlite.SqliteTransaction.Dispose(Boolean disposing)
at System.Data.Common.DbTransaction.DisposeAsync()
at Microsoft.EntityFrameworkCore.Storage.RelationalTransaction.DisposeAsync()
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(DbContext _, ValueTuple`2
parameters, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1
entriesToSave, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
at CoreApp.API.Data.CoreRepository.SaveAll() in X:\DEV\CoreApp\CoreApp.API\Data\CoreRepository.cs:line 113
at CoreApp.API.Helpers.LogUserActivity.OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) in X:\DEV\CoreApp\CoreApp.API\Helpers\LogUserActivity.cs:line 20
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
Another piece of info: if i try to open my DB in DB Browser and manully insert a row, it says
Error while saving the database file. no such savepoint: RESTOREPOINT (RELEASE "RESTOREPOINT";)
It seems that this behavior started suddenly and even though i try to delete the latest work i have typed, it still gives me this error. I also tried drop and recreate the DB a couple of times without success. I do not know how this error started or how to go about it. Thanks for the help.
Just managed to make it work but I am not sure why.
The two errors seemed to be related to disk space according to search results. Even though my application was in a folder on the company network with plenty of space available, it might have been shocking on some disk issues. I copied the whole application folder on my local machine and it works just like it used to.
Related
We currently have a site on IIS where the outside can go on and make payments, and the payment goes through an API to a third party and payment can be seen there. We also have a database that is on a different server than the site.
We have been getting an error "Exception of type 'System.OutOfMemoryException' was thrown" when payments try to come in and it seems to keep fixing by itself without us doing anything other than logging in to the server and sometimes restarting the server. For example, when customers try to make a transaction online, they will get this error sometimes. If they try again later, then it may go through successfully without error.
Is anyone familiar with this error and know where to look or begin?
Thank you
Exception of type 'System.OutOfMemoryException' was thrown.
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.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
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:
[OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.]
System.Runtime.CompilerServices.RuntimeHelpers._CompileMethod(IRuntimeMethodInfo method) +0
System.Reflection.Emit.DynamicMethod.CreateDelegate(Type delegateType, Object target) +41
System.Linq.Expressions.Expression`1.Compile() +187
System.Data.Common.Internal.Materialization.Translator.Compile(Expression body) +154
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +76
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +211
System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +35
System.Data.Common.Internal.Materialization.Translator.Compile(Type resultType, Expression body) +237
System.Data.Common.Internal.Materialization.ReplacementExpressionVisitor.Visit(Expression expression) +222
System.Linq.Expressions.EntityExpressionVisitor.VisitExpressionList(ReadOnlyCollection`1 original) +155
System.Linq.Expressions.E
This is a common error when the application does not make proper use of server resources. Search for memory leaks in the code and other bad practices that could be affecting the performance. In the mean time you could just recycle the app pool several times a day, Its better than restarting the IIS process and cause less troubles to the clients.
You can checkout this link for more info
I have a very, very similar problem to this one.
Hi.
I have an application (Service) targeting .NET 4.61 and trying to move to AspNetCore self host with WebListener.
I am trying to investigate the requirements by testing it out in a console application.
The project i crated is a normal Windows console application, i referenced all the required packages with nuget and created required Startup class and create and start the host with WebHostBuilder.
(I don't have a normal Windows console application, but a dotnet console application on my ubuntu laptop)
We've differed a little bit in what we've tried and tested before hand.
Up until now I just made a HomeController and had Index return a string with "Hello world". Ran the application, went to localhost and got the response. Perfect.
Now all I've added was that Index return an IActionResult by returning View(). Then I made an Index.cshtml file in /Views/Home/ and now I get this:
Stack trace:
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0]
An unhandled exception has occurred: One or more compilation failures occurred:
followed by 150 lines like this:
gee1fd0w.wuj(4,11): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
gee1fd0w.wuj(5,11): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
gee1fd0w.wuj(6,11): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
...
gee1fd0w.wuj(37,13): error CS0518: Predefined type 'System.Object' is not defined or imported
gee1fd0w.wuj(37,13): error CS0518: Predefined type 'System.Void' is not defined or imported
ending with:
gee1fd0w.wuj(33,36): error CS0161: '_Views_Home_Index_cshtml.ExecuteAsync()': not all code paths return a value
at Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationResult.EnsureSuccessful()
at Microsoft.AspNetCore.Mvc.Razor.Internal.CompilerCache.CreateCacheEntry(String relativePath, String normalizedPath, Func'2 compile)
--- End of stack trace from previous location where exception was thrown ---
Followed by this:
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Razor.Internal.CompilerCache.GetOrAdd(String relativePath, Func'2 compile)
at Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorPageFactoryProvider.CreateFactory(String relativePath)
at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.CreateCacheResult(HashSet`1 expirationTokens, String relativePath, Boolean isMainPage)
at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.OnCacheMiss(ViewLocationExpanderContext expanderContext, ViewLocationCacheKey cacheKey)
at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.LocatePageFromViewLocations(ActionContext actionContext, String pageName, Boolean isMainPage)
at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.FindView(ActionContext context, String viewName, Boolean isMainPage)
at Microsoft.AspNetCore.Mvc.ViewEngines.CompositeViewEngine.FindView(ActionContext context, String viewName, Boolean isMainPage)
at Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor.FindView(ActionContext actionContext, ViewResult viewResult)
at Microsoft.AspNetCore.Mvc.ViewResult.d__26.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
Followed by a series of shorter stack traces:
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__30.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__28.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ResultExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Builder.RouterMiddleware.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.d__6.MoveNext()
End of stack trace
Now I'm not sure that I fully understand the answer the previous poster got:
Mvc's runtime compilation relies on DependencyContext (deps file) to look up compilation references which is only produced when you compile using dotnet CLI. You would have to add compilation references as part of the application startup for view compilation to work.
I did compile through dotnet cli, but is there something else that I'm missing here? When I try to replicate my project by running dotnet new mvc and deleting everything but the things that are in my console-project. It runs right as rain and I get hello world from my Index.cshtml.
Instinct tells me that the problem lies in some file-difference, but I've diffed all of the files and I can't find any difference but app-name. I could have missed something but I'm wondering if it could perhaps be something automagical that I'm not aware of?
EDIT:
Have found the issue, looks like it's a difference in their generated bin/debug/netcoreapp1.1/<appname>.deps.json. Quite a few differences, going to look into it now. But if I copy paste that file from the mvc-project to the console app, everything runs ok.
Unfortunately the console applications deps.json-file is 1300+ lines long and the mvc applications version is 4300+ lines long so I'm not entirely sure it will be feasible to go through it and identifying why one works and the other don't.
EDIT:
It mostly seems to be a whole lot of dependency scopes that differ, a whole lot of the mvc ones contain dependencies to "NETStandard.Library": "1.6.1", but many others as well. There's also a bunch of compile-scopes that the console-application don't have.
In fact this seems to be the only difference. The mvc-application's deps.json-file seem to have ~3000 more lines of dependencies and compile-scopes. So I think I'll give up the idea of figuring out what's causing the problem and and my plan to learn how to "build a console app into an mvc-app" :)
I'll leave the question here in case anyone find themselves in a similar situation.
I have had this happen to me before.
Do a dotnet restore and delete your obj and bin directories.
I may not be technically correct but I think what's happening here is your old build is creating conflicts with your new build that has new (or different) references.
I had the same problem when I moved some of my classes to subdirectory and changed their namespaces. In my case deleting obj and bin directories, as well as running dotnet restore wasn't enough.
I had to change all the references to the old folder in all cshtml files(_ViewImports.cshtml for example) if you used full path as reference to models. So from using ProjectName.Models to using ProjectName.Models.NewDirectory and so on. And then deleting obj bin and running the dotnet command.
This should be fixed by using dotnet restore.
EDIT: Never mind, I see a comment already answered it.
I had this issue with a (ASP).NET Core project. The root cause was because the .csproj file was automagically updated after I mistakenly deleted the backing class of my Razor page (the .cshtml.cs file I deleted). The .csproj file captured an update that explicitly kept the PageModel class out of the build hence the error.
Background info:
I mistakenly deleted a PageModel file (.cshtml.cs) but quickly undid the delete via my Git repo. I did not realize the .csproj file was also updated.
I'm trying to handle network failure exceptions when using Google Drive SDK and I have the following problem.
I'm disconnecting my network and running this code
try
{
FilesResource.InsertRequest r = service_.Files.Insert(body);
r.Fetch();
} catch
{
Console.WriteLine("Error");
}
but instead of printing "Error" the application is terminated due to unhandled exception.
Debugger shows the following stack trace
Unable to connect to the remote server
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult)
at Google.Apis.Requests.Request.EndAttachBody(IAsyncResult asyncResult) in c:\code.google.com\google-api-dotnet-client\default_release\Tools\BuildRelease\bin\Debug\output\default\Src\GoogleApis\Apis\Requests\Request.cs:line 714
at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
at System.Net.ContextAwareResult.CompleteCallback(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Net.ContextAwareResult.Complete(IntPtr userToken)
at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
at System.Net.HttpWebRequest.SetResponse(Exception E)
at System.Net.HttpWebRequest.SetAndOrProcessResponse(Object responseOrException)
at System.Net.ConnectionReturnResult.SetResponses(ConnectionReturnResult returnResult)
Looks like Fetch() does some asynchronous operations inside and the exception is not handled. So I can't find a way handling this exception. It always terminates my application. How can I fix that?
update
I found this line of code
Stream bodyStream = request.EndGetRequestStream(asyncResult);
in Src\GoogleApis.Tests\Apis\Requests\RequestTest.cs:731
EndGetRequestStream throws an exception which is unhandled by the thread, so it looks like this is a bug in Client API. Am I right? Any workarounds?
update
Any answers? That's very important. My application crashes every time I disconnect the network and this cannot be solved without touching Google API source codes. I changed BeginGetResponse() to GetResponse() and recompiled the code, so currently it works for me and Fetch() throws an exception as expected, but synchronous and asynchronous operations are sharing a common code (synchronous operation executes asynchronous and waits) so currently I can't do async fetch. Will you guys fix this?
update
Google says We support the Google Drive SDK on Stack Overflow.
Guys, do you really provide kind of support for your SDK? I'm waiting for ANY answer almost 5 days. Is there anybody?
Sorry for the delay.
It looks like a bug and I just opened a new issue in our issue tracker - you can add more details to it here.
We will try to fix it in the next release.
In the next couple of weeks we are going to publish version 1.4.0-beta which has a fix for this problem. Just to let you know, the new version of Google.Apis core library will be PCL. It requires upgrading the .NET framework to 4.0, and there is a great usage of TPL.
I am trying to use UIA to control browsers (ie, chrome, firefox) operations like nativate, go back, go forward and so on for some testing necessary. I tried to wrote some demo code, but met some problems. I got the AutomationElement for address edit for Chrome, and try to set url for it with ValuePattern, but I got exception below:
在 System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
在 MS.Internal.Automation.UiaCoreApi.CheckError(Int32 hr)
在 System.Windows.Automation.ValuePattern.SetValue(String value)
在 BrowserControl.Browser.Browser.Goto(String url) 位置 C:\Users\darren\documents\visual studio 2010\Projects\BrowserControl\BrowserControl\Browser\Browser.cs:行号 109
在 BrowserControl.Program.Main(String[] args) 位置 C:\Users\darren\documents\visual studio 2010\Projects\BrowserControl\BrowserControl\Program.cs:行号 17
在 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
And I found that SetFoucus method also will got the same exception. I tried to use win32 method to send message to it, found that the element.Current.NativeWindowHandle is null. but I can see the current value from ValuePattern's current property.
Just for a address that the UIA cannot find the chrome's control firstly until I called the below method ()UiaRegisterProviderCallback(IntPtr.Zero);
So, not sure what's reason for it, and is there anyway to set value for chrome's control
I can't be certain of this without digging into the Chrome source, but my guess would be that the address bar in Chrome is actually a custom control and that's why you aren't seeing it conform perfectly to the ValuePattern like a standard textbox/editbox. I've seen things like this pop up elsewhere, and I usually end up doing some sort of workaround using SendKeys.
I encountered this issue too and it sometimes occur and sometimes not despite using the exact same code, which confused me greatly. Then I discovered that Chrome doesn't always turn on accessibility until it detects assistive software for performance reasons. Adding the --force-renderer-accessibility flag solved the issue.
I deployed a web service that used WSE 3.0 to a test server. I am getting the cryptic error below. Have any idea what this means and how to fix it? Thanks in advance!
Microsoft.Web.Services3.ResponseProcessingException: WSE910: An error happened during the processing of a response message, and you can find the error in the inner exception. You can also find the response message in the Response property. ---> System.Xml.XmlException: 'wsse' is an undeclared namespace. Line 1, position 97.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg, Int32 lineNo, Int32 linePos)
at System.Xml.XmlTextReaderImpl.LookupNamespace(NodeData node)
at System.Xml.XmlTextReaderImpl.ElementNamespaceLookup()
at System.Xml.XmlTextReaderImpl.ParseAttributes()
at System.Xml.XmlTextReaderImpl.ParseElement()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at Microsoft.Web.Services3.Xml.XmlSkipDTDReader.Read()
at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at Microsoft.Web.Services3.SoapEnvelope.Load(Stream inStream)
at Microsoft.Web.Services3.Xml.SoapEnvelopeReaderWrapper..ctor(SoapClientMessage message, String messageContentType)
--- End of inner exception stack trace ---
at Microsoft.Web.Services3.Xml.SoapEnvelopeReaderWrapper..ctor(SoapClientMessage message, String messageContentType)
at Microsoft.Web.Services3.WebServicesClientProtocol.GetReaderForMessage(SoapClientMessage message, Int32 bufferSize)
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
I found a solution. Since the dll was working when I called it from a windows client but was failing when called from a web service I suspected that the problem might be permissions related. I set the web service to impersonate a user with sufficient permissions. See http://support.microsoft.com/kb/306158 for how to information. Now it works. Hope this helps someone else, Dan
System.Xml.XmlException: 'wsse' is an undeclared namespace. Line 1, position 97.
Well if this statement is true then you have the wrong namespace. Check out your solution files to make sure they're under the write ns'es.
I got the same problem and it was a problem of date time synchronization between the server and the client. After setting the same time in the client and server, the error was fixed.