void HandleOneWayException(Exception e, string method) { if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Error, this, string.IsNullOrEmpty(method) ? "HandleOneWayException" : method, e); } // exceptions for one-way calls are dropped because the response is already written }
protected void InvokeAsync(string methodName, string requestUrl, object[] parameters, SendOrPostCallback callback, object userState) { if (userState == null) { userState = base.NullToken; } AsyncOperation userAsyncState = AsyncOperationManager.CreateOperation(new UserToken(callback, userState)); WebClientAsyncResult result = new WebClientAsyncResult(this, null, null, new AsyncCallback(this.InvokeAsyncCallback), userAsyncState); try { base.AsyncInvokes.Add(userState, result); } catch (Exception exception) { if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException)) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Error, this, "InvokeAsync", exception); } Exception exception2 = new ArgumentException(Res.GetString("AsyncDuplicateUserState"), exception); object[] results = new object[1]; InvokeCompletedEventArgs arg = new InvokeCompletedEventArgs(results, exception2, false, userState); userAsyncState.PostOperationCompleted(callback, arg); return; } try { HttpClientMethod clientMethod = this.GetClientMethod(methodName); MimeParameterWriter parameterWriter = this.GetParameterWriter(clientMethod); Uri requestUri = new Uri(requestUrl); if (parameterWriter != null) { parameterWriter.RequestEncoding = base.RequestEncoding; requestUrl = parameterWriter.GetRequestUrl(requestUri.AbsoluteUri, parameters); requestUri = new Uri(requestUrl, true); } result.InternalAsyncState = new InvokeAsyncState(clientMethod, parameterWriter, parameters); base.BeginSend(requestUri, result, parameterWriter.UsesWriteRequest); } catch (Exception exception3) { if (((exception3 is ThreadAbortException) || (exception3 is StackOverflowException)) || (exception3 is OutOfMemoryException)) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Error, this, "InvokeAsync", exception3); } object[] objArray2 = new object[1]; base.OperationCompleted(userState, objArray2, exception3, false); } }
internal void Complete() { try { if (this.ResponseStream != null) { this.ResponseStream.Close(); this.ResponseStream = null; } if (this.ResponseBufferedStream != null) { this.ResponseBufferedStream.Position = 0L; } } catch (System.Exception exception) { if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException)) { throw; } if (this.Exception == null) { this.Exception = exception; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Error, this, "Complete", exception); } } this.isCompleted = true; try { if (this.manualResetEvent != null) { this.manualResetEvent.Set(); } } catch (System.Exception exception2) { if (((exception2 is ThreadAbortException) || (exception2 is StackOverflowException)) || (exception2 is OutOfMemoryException)) { throw; } if (this.Exception == null) { this.Exception = exception2; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Error, this, "Complete", exception2); } } if (this.userCallback != null) { this.userCallback(this); } }
public void ResolveAll() { this.Errors.Clear(); int count = this.InlinedSchemas.Keys.Count; while (count != this.References.Count) { count = this.References.Count; DiscoveryReference[] array = new DiscoveryReference[this.References.Count]; this.References.Values.CopyTo(array, 0); for (int i = 0; i < array.Length; i++) { DiscoveryReference reference = array[i]; if (reference is DiscoveryDocumentReference) { try { ((DiscoveryDocumentReference)reference).ResolveAll(true); } catch (Exception exception) { if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException)) { throw; } this.Errors[reference.Url] = exception; if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "ResolveAll", exception); } } } else { try { reference.Resolve(); } catch (Exception exception2) { if (((exception2 is ThreadAbortException) || (exception2 is StackOverflowException)) || (exception2 is OutOfMemoryException)) { throw; } this.Errors[reference.Url] = exception2; if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "ResolveAll", exception2); } } } } } this.FixupReferences(); }
public void ResolveAll() { // Resolve until we reach a 'steady state' (no more references added) Errors.Clear(); int resolvedCount = InlinedSchemas.Keys.Count; while (resolvedCount != References.Count) { resolvedCount = References.Count; DiscoveryReference[] refs = new DiscoveryReference[References.Count]; References.Values.CopyTo(refs, 0); for (int i = 0; i < refs.Length; i++) { DiscoveryReference discoRef = refs[i]; if (discoRef is DiscoveryDocumentReference) { try { // Resolve discovery document references deeply ((DiscoveryDocumentReference)discoRef).ResolveAll(true); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } // don't let the exception out - keep going. Just add it to the list of errors. Errors[discoRef.Url] = e; if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "ResolveAll", e); } } } else { try { discoRef.Resolve(); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } // don't let the exception out - keep going. Just add it to the list of errors. Errors[discoRef.Url] = e; if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "ResolveAll", e); } } } } } FixupReferences(); }
void Invoke() { PrepareContext(); protocol.CreateServerInstance(); string stringBuffer; #if !MONO RemoteDebugger debugger = null; if (!protocol.IsOneWay && RemoteDebugger.IsServerCallInEnabled(protocol, out stringBuffer)) { debugger = new RemoteDebugger(); debugger.NotifyServerCallEnter(protocol, stringBuffer); } #endif try { TraceMethod caller = Tracing.On ? new TraceMethod(this, "Invoke") : null; TraceMethod userMethod = Tracing.On ? new TraceMethod(protocol.Target, protocol.MethodInfo.Name, this.parameters) : null; if (Tracing.On) { Tracing.Enter(protocol.MethodInfo.ToString(), caller, userMethod); } object[] returnValues = protocol.MethodInfo.Invoke(protocol.Target, this.parameters); if (Tracing.On) { Tracing.Exit(protocol.MethodInfo.ToString(), caller); } WriteReturns(returnValues); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Error, this, "Invoke", e); } if (!protocol.IsOneWay) { WriteException(e); throw; } } finally { protocol.DisposeServerInstance(); #if !MONO if (debugger != null) { debugger.NotifyServerCallExit(protocol.Response); } #endif } }
protected override DirectoryInfo GetPhysicalDir(string dir) { DirectoryEntry entry = (DirectoryEntry)this.Adsi[dir]; if (entry == null) { if (!DirectoryEntry.Exists(dir)) { return(null); } entry = new DirectoryEntry(dir); this.Adsi[dir] = entry; } try { DirectoryInfo info = null; AppSettings appSettings = this.GetAppSettings(entry); if (appSettings == null) { return(null); } if (appSettings.VPath == null) { if (!dir.StartsWith(this.rootPathAsdi, StringComparison.Ordinal)) { throw new ArgumentException(System.Web.Services.Res.GetString("WebVirtualDisoRoot", new object[] { dir, this.rootPathAsdi }), "dir"); } string str = dir.Substring(this.rootPathAsdi.Length).Replace('/', '\\'); info = new DirectoryInfo(this.startDir + str); } else { info = new DirectoryInfo(appSettings.VPath); } if (info.Exists) { return(info); } } catch (Exception exception) { if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException)) { throw; } bool traceVerbose = System.ComponentModel.CompModSwitches.DynamicDiscoverySearcher.TraceVerbose; if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "GetPhysicalDir", exception); } return(null); } return(null); }
private void Invoke() { string str; this.PrepareContext(); this.protocol.CreateServerInstance(); RemoteDebugger debugger = null; if (!this.protocol.IsOneWay && RemoteDebugger.IsServerCallInEnabled(this.protocol, out str)) { debugger = new RemoteDebugger(); debugger.NotifyServerCallEnter(this.protocol, str); } try { TraceMethod caller = Tracing.On ? new TraceMethod(this, "Invoke", new object[0]) : null; TraceMethod callDetails = Tracing.On ? new TraceMethod(this.protocol.Target, this.protocol.MethodInfo.Name, this.parameters) : null; if (Tracing.On) { Tracing.Enter(this.protocol.MethodInfo.ToString(), caller, callDetails); } object[] returnValues = this.protocol.MethodInfo.Invoke(this.protocol.Target, this.parameters); if (Tracing.On) { Tracing.Exit(this.protocol.MethodInfo.ToString(), caller); } this.WriteReturns(returnValues); } catch (Exception exception) { if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException)) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Error, this, "Invoke", exception); } if (!this.protocol.IsOneWay) { this.WriteException(exception); throw; } } finally { this.protocol.DisposeServerInstance(); if (debugger != null) { debugger.NotifyServerCallExit(this.protocol.Response); } } }
internal void NotifyServerCallExit(HttpResponse response) { try { if (NotifySink == null) { return; } IntPtr bufferPtr; int bufferSize = 0; CallId callId = new CallId(null, 0, (IntPtr)0, 0, null, null); TraceMethod method = Tracing.On ? new TraceMethod(this, "NotifyServerCallExit") : null; if (Tracing.On) { Tracing.Enter("RemoteDebugger", method); } UnsafeNativeMethods.OnSyncCallExit(NotifySink, callId, out bufferPtr, ref bufferSize); if (Tracing.On) { Tracing.Exit("RemoteDebugger", method); } if (bufferPtr == IntPtr.Zero) { return; } byte[] buffer = null; try { buffer = new byte[bufferSize]; Marshal.Copy(bufferPtr, buffer, 0, bufferSize); } finally { Marshal.FreeCoTaskMem(bufferPtr); } string stringBuffer = Convert.ToBase64String(buffer); response.AddHeader(debuggerHeader, stringBuffer); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, typeof(RemoteDebugger), "NotifyServerCallExit", e); } } this.Close(); }
/// <include file='doc\HttpClientProtocol.uex' path='docs/doc[@for="HttpSimpleClientProtocol.InvokeAsync1"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> protected void InvokeAsync(string methodName, string requestUrl, object[] parameters, SendOrPostCallback callback, object userState) { if (userState == null) { userState = NullToken; } AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(new UserToken(callback, userState)); WebClientAsyncResult asyncResult = new WebClientAsyncResult(this, null, null, new AsyncCallback(InvokeAsyncCallback), asyncOp); try { AsyncInvokes.Add(userState, asyncResult); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Error, this, "InvokeAsync", e); } Exception exception = new ArgumentException(Res.GetString(Res.AsyncDuplicateUserState), e); InvokeCompletedEventArgs eventArgs = new InvokeCompletedEventArgs(new object[] { null }, exception, false, userState); asyncOp.PostOperationCompleted(callback, eventArgs); return; } try { HttpClientMethod method = GetClientMethod(methodName); MimeParameterWriter paramWriter = GetParameterWriter(method); Uri requestUri = new Uri(requestUrl); if (paramWriter != null) { paramWriter.RequestEncoding = RequestEncoding; requestUrl = paramWriter.GetRequestUrl(requestUri.AbsoluteUri, parameters); requestUri = new Uri(requestUrl, true); } asyncResult.InternalAsyncState = new InvokeAsyncState(method, paramWriter, parameters); BeginSend(requestUri, asyncResult, paramWriter.UsesWriteRequest); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Error, this, "InvokeAsync", e); } OperationCompleted(userState, new object[] { null }, e, false); } }
internal void NotifyServerCallEnter(ServerProtocol protocol, string stringBuffer) { try { if (NotifySink == null) { return; } StringBuilder methodBuilder = new StringBuilder(); methodBuilder.Append(protocol.Type.FullName); methodBuilder.Append('.'); methodBuilder.Append(protocol.MethodInfo.Name); methodBuilder.Append('('); ParameterInfo[] parameterInfos = protocol.MethodInfo.Parameters; for (int i = 0; i < parameterInfos.Length; ++i) { if (i != 0) { methodBuilder.Append(','); } methodBuilder.Append(parameterInfos[i].ParameterType.FullName); } methodBuilder.Append(')'); byte[] buffer = Convert.FromBase64String(stringBuffer); CallId callId = new CallId(null, 0, (IntPtr)0, 0, methodBuilder.ToString(), null); TraceMethod method = Tracing.On ? new TraceMethod(this, "NotifyServerCallEnter") : null; if (Tracing.On) { Tracing.Enter("RemoteDebugger", method); } UnsafeNativeMethods.OnSyncCallEnter(NotifySink, callId, buffer, buffer.Length); if (Tracing.On) { Tracing.Exit("RemoteDebugger", method); } } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, typeof(RemoteDebugger), "NotifyServerCallEnter", e); } } }
internal void NotifyServerCallExit(HttpResponse response) { try { IntPtr ptr; if (this.NotifySink == null) { return; } int num = 0; CallId callId = new CallId(null, 0, IntPtr.Zero, 0L, null, null); TraceMethod caller = Tracing.On ? new TraceMethod(this, "NotifyServerCallExit", new object[0]) : null; if (Tracing.On) { Tracing.Enter("RemoteDebugger", caller); } System.Web.Services.UnsafeNativeMethods.OnSyncCallExit(this.NotifySink, callId, out ptr, ref num); if (Tracing.On) { Tracing.Exit("RemoteDebugger", caller); } if (ptr == IntPtr.Zero) { return; } byte[] destination = null; try { destination = new byte[num]; Marshal.Copy(ptr, destination, 0, num); } finally { Marshal.FreeCoTaskMem(ptr); } string str = Convert.ToBase64String(destination); response.AddHeader(debuggerHeader, str); } catch (Exception exception) { if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException)) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, typeof(RemoteDebugger), "NotifyServerCallExit", exception); } } this.Close(); }
protected void InvokeAsync(string methodName, object[] parameters, SendOrPostCallback callback, object userState) { if (userState == null) { userState = this.NullToken; } SoapHttpClientProtocol.InvokeAsyncState invokeAsyncState = new SoapHttpClientProtocol.InvokeAsyncState(methodName, parameters); AsyncOperation operation = AsyncOperationManager.CreateOperation((object)new UserToken(callback, userState)); WebClientAsyncResult asyncResult = new WebClientAsyncResult((WebClientProtocol)this, (object)invokeAsyncState, (WebRequest)null, new AsyncCallback(this.InvokeAsyncCallback), (object)operation); try { this.AsyncInvokes.Add(userState, (object)asyncResult); } catch (Exception ex) { if (ex is ThreadAbortException || ex is StackOverflowException || ex is OutOfMemoryException) { throw; } else { if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, (object)this, "InvokeAsync", ex); } InvokeCompletedEventArgs completedEventArgs = new InvokeCompletedEventArgs(new object[1], (Exception) new ArgumentException(System.Web.Services.Res.GetString("AsyncDuplicateUserState"), ex), false, userState); operation.PostOperationCompleted(callback, (object)completedEventArgs); return; } } try { this.BeginSend(this.Uri, asyncResult, true); } catch (Exception ex) { if (ex is ThreadAbortException || ex is StackOverflowException || ex is OutOfMemoryException) { throw; } else { if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, (object)this, "InvokeAsync", ex); } this.OperationCompleted(userState, new object[1], ex, false); } } }
private void InvokeAsyncCallback(IAsyncResult result) { object[] parameters = null; Exception e = null; WebClientAsyncResult asyncResult = (WebClientAsyncResult)result; if (asyncResult.Request != null) { object internalAsyncState = null; Stream responseStream = null; try { WebResponse response = base.EndSend(asyncResult, ref internalAsyncState, ref responseStream); InvokeAsyncState state = (InvokeAsyncState)internalAsyncState; parameters = this.ReadResponse(state.Message, response, responseStream, true); } catch (XmlException exception2) { if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "InvokeAsyncCallback", exception2); } e = new InvalidOperationException(System.Web.Services.Res.GetString("WebResponseBadXml"), exception2); } catch (Exception exception3) { if (((exception3 is ThreadAbortException) || (exception3 is StackOverflowException)) || (exception3 is OutOfMemoryException)) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "InvokeAsyncCallback", exception3); } e = exception3; } finally { if (responseStream != null) { responseStream.Close(); } } } AsyncOperation asyncState = (AsyncOperation)result.AsyncState; UserToken userSuppliedState = (UserToken)asyncState.UserSuppliedState; base.OperationCompleted(userSuppliedState.UserState, parameters, e, false); }
protected void InvokeAsync(string methodName, object[] parameters, SendOrPostCallback callback, object userState) { if (userState == null) { userState = base.NullToken; } InvokeAsyncState internalAsyncState = new InvokeAsyncState(methodName, parameters); AsyncOperation userAsyncState = AsyncOperationManager.CreateOperation(new UserToken(callback, userState)); WebClientAsyncResult result = new WebClientAsyncResult(this, internalAsyncState, null, new AsyncCallback(this.InvokeAsyncCallback), userAsyncState); try { base.AsyncInvokes.Add(userState, result); } catch (Exception exception) { if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException)) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "InvokeAsync", exception); } Exception exception2 = new ArgumentException(System.Web.Services.Res.GetString("AsyncDuplicateUserState"), exception); object[] results = new object[1]; InvokeCompletedEventArgs arg = new InvokeCompletedEventArgs(results, exception2, false, userState); userAsyncState.PostOperationCompleted(callback, arg); return; } try { base.BeginSend(base.Uri, result, true); } catch (Exception exception3) { if (((exception3 is ThreadAbortException) || (exception3 is StackOverflowException)) || (exception3 is OutOfMemoryException)) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "InvokeAsync", exception3); } object[] objArray2 = new object[1]; base.OperationCompleted(userState, objArray2, exception3, false); } }
private void InvokeAsyncCallback(IAsyncResult result) { object[] parameters = (object[])null; Exception e = (Exception)null; WebClientAsyncResult clientAsyncResult = (WebClientAsyncResult)result; if (clientAsyncResult.Request != null) { object internalAsyncState = (object)null; Stream responseStream = (Stream)null; try { WebResponse response = this.EndSend((IAsyncResult)clientAsyncResult, ref internalAsyncState, ref responseStream); parameters = this.ReadResponse(((SoapHttpClientProtocol.InvokeAsyncState)internalAsyncState).Message, response, responseStream, true); } catch (XmlException ex) { if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, (object)this, "InvokeAsyncCallback", (Exception)ex); } e = (Exception) new InvalidOperationException(System.Web.Services.Res.GetString("WebResponseBadXml"), (Exception)ex); } catch (Exception ex) { if (ex is ThreadAbortException || ex is StackOverflowException || ex is OutOfMemoryException) { throw; } else { if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, (object)this, "InvokeAsyncCallback", ex); } e = ex; } } finally { if (responseStream != null) { responseStream.Close(); } } } this.OperationCompleted(((UserToken)((AsyncOperation)result.AsyncState).UserSuppliedState).UserState, parameters, e, false); }
internal void NotifyServerCallEnter(ServerProtocol protocol, string stringBuffer) { try { if (this.NotifySink != null) { StringBuilder builder = new StringBuilder(); builder.Append(protocol.Type.FullName); builder.Append('.'); builder.Append(protocol.MethodInfo.Name); builder.Append('('); ParameterInfo[] parameters = protocol.MethodInfo.Parameters; for (int i = 0; i < parameters.Length; i++) { if (i != 0) { builder.Append(','); } builder.Append(parameters[i].ParameterType.FullName); } builder.Append(')'); byte[] buffer = Convert.FromBase64String(stringBuffer); CallId callId = new CallId(null, 0, IntPtr.Zero, 0L, builder.ToString(), null); TraceMethod caller = Tracing.On ? new TraceMethod(this, "NotifyServerCallEnter", new object[0]) : null; if (Tracing.On) { Tracing.Enter("RemoteDebugger", caller); } System.Web.Services.UnsafeNativeMethods.OnSyncCallEnter(this.NotifySink, callId, buffer, buffer.Length); if (Tracing.On) { Tracing.Exit("RemoteDebugger", caller); } } } catch (Exception exception) { if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException)) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, typeof(RemoteDebugger), "NotifyServerCallEnter", exception); } } }
private IAsyncResult BeginInvoke(AsyncCallback callback, object asyncState) { IAsyncResult asyncResult; try { PrepareContext(); protocol.CreateServerInstance(); this.asyncCallback = callback; TraceMethod caller = Tracing.On ? new TraceMethod(this, "BeginInvoke") : null; TraceMethod userMethod = Tracing.On ? new TraceMethod(protocol.Target, protocol.MethodInfo.Name, this.parameters) : null; if (Tracing.On) { Tracing.Enter(protocol.MethodInfo.ToString(), caller, userMethod); } asyncResult = protocol.MethodInfo.BeginInvoke(protocol.Target, this.parameters, new AsyncCallback(this.Callback), asyncState); if (Tracing.On) { Tracing.Enter(protocol.MethodInfo.ToString(), caller); } if (asyncResult == null) { throw new InvalidOperationException(Res.GetString(Res.WebNullAsyncResultInBegin)); } } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Error, this, "BeginInvoke", e); } // save off the exception and throw it in EndCoreProcessRequest exception = e; asyncResult = new CompletedAsyncResult(asyncState, true); this.asyncCallback = callback; this.DoCallback(asyncResult); } this.asyncBeginComplete.Set(); TraceFlush(); return(asyncResult); }
private void InvokeAsyncCallback(IAsyncResult result) { object[] parameters = null; Exception exception = null; WebClientAsyncResult asyncResult = (WebClientAsyncResult)result; if (asyncResult.Request != null) { object o = null; Stream responseStream = null; try { WebResponse response = EndSend(asyncResult, ref o, ref responseStream); InvokeAsyncState invokeState = (InvokeAsyncState)o; parameters = ReadResponse(invokeState.Message, response, responseStream, true); } catch (XmlException e) { if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "InvokeAsyncCallback", e); } exception = new InvalidOperationException(Res.GetString(Res.WebResponseBadXml), e); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "InvokeAsyncCallback", e); } exception = e; } finally { if (responseStream != null) { responseStream.Close(); } } } AsyncOperation asyncOp = (AsyncOperation)result.AsyncState; UserToken token = (UserToken)asyncOp.UserSuppliedState; OperationCompleted(token.UserState, parameters, exception, false); }
internal void NotifyClientCallReturn(WebResponse response) { try { if (NotifySink == null) { return; } byte[] buffer = new byte[0]; if (response != null) { string bufferString = response.Headers[debuggerHeader]; if (bufferString != null && bufferString.Length != 0) { buffer = Convert.FromBase64String(bufferString); } } CallId callId = new CallId(null, 0, (IntPtr)0, 0, null, null); TraceMethod method = Tracing.On ? new TraceMethod(this, "NotifyClientCallReturn") : null; if (Tracing.On) { Tracing.Enter("RemoteDebugger", method); } UnsafeNativeMethods.OnSyncCallReturn(NotifySink, callId, buffer, buffer.Length); if (Tracing.On) { Tracing.Exit("RemoteDebugger", method); } } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, typeof(RemoteDebugger), "NotifyClientCallReturn", e); } } this.Close(); }
internal Exception AttemptResolve(string contentType, Stream stream) { try { Resolve(contentType, stream); return(null); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "AttemptResolve", e); } return(e); } }
private IAsyncResult BeginInvoke(AsyncCallback callback, object asyncState) { IAsyncResult result; try { this.PrepareContext(); this.protocol.CreateServerInstance(); this.asyncCallback = callback; TraceMethod caller = Tracing.On ? new TraceMethod(this, "BeginInvoke", new object[0]) : null; TraceMethod callDetails = Tracing.On ? new TraceMethod(this.protocol.Target, this.protocol.MethodInfo.Name, this.parameters) : null; if (Tracing.On) { Tracing.Enter(this.protocol.MethodInfo.ToString(), caller, callDetails); } result = this.protocol.MethodInfo.BeginInvoke(this.protocol.Target, this.parameters, new AsyncCallback(this.Callback), asyncState); if (Tracing.On) { Tracing.Enter(this.protocol.MethodInfo.ToString(), caller); } if (result == null) { throw new InvalidOperationException(Res.GetString("WebNullAsyncResultInBegin")); } } catch (Exception exception) { if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException)) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Error, this, "BeginInvoke", exception); } this.exception = exception; result = new CompletedAsyncResult(asyncState, true); this.asyncCallback = callback; this.DoCallback(result); } this.asyncBeginComplete.Set(); TraceFlush(); return(result); }
internal static bool IsClientCallOutEnabled() { bool enabled = false; try { enabled = !CompModSwitches.DisableRemoteDebugging.Enabled && Debugger.IsAttached && Connection != null; } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, typeof(RemoteDebugger), "IsClientCallOutEnabled", e); } } return(enabled); }
internal XmlSchema GetSchema() { try { return(Schema); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } // don't let the exception out - keep going. Just add it to the list of errors. ClientProtocol.Errors[Url] = e; if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "GetSchema", e); } } return(null); }
internal void NotifyClientCallReturn(WebResponse response) { try { if (this.NotifySink == null) { return; } byte[] buffer = new byte[0]; if (response != null) { string s = response.Headers[debuggerHeader]; if ((s != null) && (s.Length != 0)) { buffer = Convert.FromBase64String(s); } } CallId callId = new CallId(null, 0, IntPtr.Zero, 0L, null, null); TraceMethod caller = Tracing.On ? new TraceMethod(this, "NotifyClientCallReturn", new object[0]) : null; if (Tracing.On) { Tracing.Enter("RemoteDebugger", caller); } System.Web.Services.UnsafeNativeMethods.OnSyncCallReturn(this.NotifySink, callId, buffer, buffer.Length); if (Tracing.On) { Tracing.Exit("RemoteDebugger", caller); } } catch (Exception exception) { if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException)) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, typeof(RemoteDebugger), "NotifyClientCallReturn", exception); } } this.Close(); }
/// <include file='doc\SoapClientProtocol.uex' path='docs/doc[@for="SoapClientProtocol.InvokeAsync1"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> protected void InvokeAsync(string methodName, object[] parameters, SendOrPostCallback callback, object userState) { if (userState == null) { userState = NullToken; } InvokeAsyncState invokeState = new InvokeAsyncState(methodName, parameters); AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(new UserToken(callback, userState)); WebClientAsyncResult asyncResult = new WebClientAsyncResult(this, invokeState, null, new AsyncCallback(InvokeAsyncCallback), asyncOp); try { AsyncInvokes.Add(userState, asyncResult); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "InvokeAsync", e); } Exception exception = new ArgumentException(Res.GetString(Res.AsyncDuplicateUserState), e); InvokeCompletedEventArgs eventArgs = new InvokeCompletedEventArgs(new object[] { null }, exception, false, userState); asyncOp.PostOperationCompleted(callback, eventArgs); return; } try { BeginSend(Uri, asyncResult, true); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "InvokeAsync", e); } OperationCompleted(userState, new object[] { null }, e, false); } }
internal XmlSchema GetSchema() { try { return(this.Schema); } catch (Exception exception) { if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException)) { throw; } base.ClientProtocol.Errors[this.Url] = exception; if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "GetSchema", exception); } } return(null); }
private static void ProcessAsyncException(WebClientAsyncResult client, Exception e, string method) { if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Error, typeof(WebClientProtocol), method, e); } WebException exception = e as WebException; if ((exception != null) && (exception.Response != null)) { client.Response = exception.Response; } else { if (client.IsCompleted) { throw new InvalidOperationException(Res.GetString("ThereWasAnErrorDuringAsyncProcessing"), e); } client.Complete(e); } }
internal static bool IsClientCallOutEnabled() { bool flag = false; try { flag = (!System.ComponentModel.CompModSwitches.DisableRemoteDebugging.Enabled && Debugger.IsAttached) && (Connection != null); } catch (Exception exception) { if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException)) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, typeof(RemoteDebugger), "IsClientCallOutEnabled", exception); } } return(flag); }
/// <include file='doc\ClientProtocol.uex' path='docs/doc[@for="WebClientProtocol.GetWebResponse"]/*' /> /// <devdoc> /// <para> /// Gets the <see cref='System.Net.WebResponse'/> from the given request by calling /// GetResponse(). Derived classes can override this method to do additional /// processing on the response instance. /// </para> /// </devdoc> protected virtual WebResponse GetWebResponse(WebRequest request) { TraceMethod caller = Tracing.On ? new TraceMethod(this, "GetWebResponse") : null; WebResponse response = null; try { if (Tracing.On) { Tracing.Enter("WebRequest.GetResponse", caller, new TraceMethod(request, "GetResponse")); } response = request.GetResponse(); if (Tracing.On) { Tracing.Exit("WebRequest.GetResponse", caller); } } catch (WebException e) { if (e.Response == null) { throw e; } else { if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Error, this, "GetWebResponse", e); } response = e.Response; } } finally { #if !MONO if (debugger != null) { debugger.NotifyClientCallReturn(response); } #endif } return(response); }