public void Run(string WsdlUrl, string FileName, string PathName) { try { if ((WsdlUrl.Length > 0) && (FileName.Length > 0)) { this.wsdlurl = WsdlUrl; this.filename = PathName + FileName; this.pathname = PathName; if (!System.EnterpriseServices.Internal.NativeMethods.OpenThreadToken(System.EnterpriseServices.Internal.NativeMethods.GetCurrentThread(), 4, true, ref this.threadtoken) && (Marshal.GetLastWin32Error() != 0x3f0)) { throw new COMException(Resource.FormatString("Err_OpenThreadToken"), Marshal.GetHRForLastWin32Error()); } SafeUserTokenHandle handle = null; try { handle = new SafeUserTokenHandle(Security.SuspendImpersonation(), true); this.thisthread.Start(); } finally { if (handle != null) { Security.ResumeImpersonation(handle.DangerousGetHandle()); handle.Dispose(); } } this.thisthread.Join(); if (this.ExceptionThrown) { throw this.SavedException; } } } catch (Exception exception) { if ((exception is NullReferenceException) || (exception is SEHException)) { throw; } ComSoapPublishError.Report(exception.ToString()); throw; } }
public GenAssemblyFromWsdl() { this.thisthread = new Thread(new ThreadStart(this.Generate)); this.threadtoken = new SafeUserTokenHandle(); }
internal static extern bool SetThreadToken(IntPtr Thread, SafeUserTokenHandle Token);
internal static extern bool OpenThreadToken(IntPtr ThreadHandle, uint DesiredAccess, bool OpenAsSelf, ref SafeUserTokenHandle TokenHandle);