Google Drive SDK fetch causes unhandled exception - google-drive-api

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.

Related

cannot rollback - no transaction is active only if Angular server is started

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.

NullReference exception on reactivation of app before a call to a MobileFirst adapter returns

I am developing a windows phone 8 silverlight application and I am using
MFP v6.3
The following problem occurs.
If I make a call to a MobileFirst adapter and place the app in the background before that call returns, when I reactivate the app it crashes with this exception.
ExceptionObject {System.NullReferenceException: Object reference not set to an instance of an object.
at IBM.Worklight.WLRequest.responseCallback(IAsyncResult asyncResult)
at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClass1d.<InvokeGetResponseCallback>b__1b(Object state2)} System.Exception {System.NullReferenceException}
This happens for any call I have tried.
Does anybody know why this exception is thrown?
Secondly, I would like to know if there is a way to cancel a call. So that I can do it when my app is deactivated.
EDIT: adding adapter call implementation
public void getInvoices(IShowAndProceed showAndProceedVM, JObject parameter)
{
String myContextObject = "MyAppWP8";
WLRequestOptions invoicesOptions = new WLRequestOptions();
invoicesOptions.setInvocationContext(myContextObject);
WLProcedureInvocationData InvoicesInvocationData = new WLProcedureInvocationData("BillingAdapter", "MyInvoicesProcedure");
InvoicesInvocationData.setParameters(new Object[] { parameter });
WLClient.getInstance().invokeProcedure(InvoicesInvocationData, new InvoicesInvokeListener(showAndProceedVM), invoicesOptions);
}
Question #1:
An exception sounds like a defect to me. It will be investigated, but it will help if you will edit the question and add your implementation (for the adapter procedure call).
Edit: Please open a PMR.
Question #2:
It is not possible to 'cancel' a MFP adapter request after it has been executed. You can submit a feature request.

Breeze EF6 SaveChanges doesn't propagate exceptions

In the EFContextProvider (EF6) SaveChangesCore method, the exception handling looks like this:
} catch (Exception e) {
while (e.InnerException != null) {
e = e.InnerException;
}
throw e;
}
This throws only the most internal exception and hides the relevant information revealed by the external exceptions.
When the SaveChanges process goes through multiple layers the next direct layer exception is lost, and only the last exception in the chain is thrown. It doesn't allow to handle well the exceptions for the caller.
Updated Post
As of Breeze 1.4.6, any .NET Exceptions thrown on the server are now available in their original form in the httpResponse.data property of any async breeze result. Breeze will still drill down to extract a "good" error message, but will no longer obscure the initial exception.
Original Post Below -------------------
It's an interesting point. The reason we did this was because most client side apps aren't written to navigate thru the exception chain and we wanted to expose the most 'relevant' error to the client. Most of the apps we looked at just exposed the client "error.message" property directly and with EF errors this was almost always useless.
However, your point is well taken. I think what we need to do is create a new Exception that has a top level message that is the innermost exception message but still expose the entire exception chain for those that want to drill. I've added an internal feature request for this and will try to get it into a near term release ( probably not the next one because we are already in testing for that one).
And thanks for the input.

ValuePattern's SetValue does not work for Chrome browser's control like address edit (Exception thrown)

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.

Microsoft.Web.Services3.ResponseProcessingException

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.