I am trying to stop a remote system's IIS application pool using the following c# code:
try
{
// Assign a variable to store the Connection Options
var connection = new ConnectionOptions();
// Connect as this user
connection.Username = Globals.AdminUsername;
// Connect with this password
connection.Password = Globals.AdminPassword;
// Connect using this domain
connection.Authority = "ntlmdomain:MyDomain";
// Gets or sets a value indicating whether user privileges
// need to be enabled for the connection operation.
connection.EnablePrivileges = true;
// Enable impersonation so non admins can run admin level commands
connection.Impersonation = ImpersonationLevel.Impersonate;
//Each data packet is signed and encrypted. This helps protect
// the entire communication between the client and server.
connection.Authentication = AuthenticationLevel.PacketPrivacy;
// Define a WMI management scope
var wmiScope = new ManagementScope(String.Format("\\\\{0}\\root\\MicrosoftIISv2", ServerName), connection);
string objPath = "IISApplicationPool.Name='W3SVC/AppPools/" + AppPoolName + "'";
// Run the query using the scope defined above
using (ManagementObject AppPool = new ManagementObject(wmiScope,new ManagementPath(objPath), null))
{
switch (Action)
{
case "Start":
AppPool.InvokeMethod("Start", null, null);
break;
case "Stop":
AppPool.InvokeMethod("Stop", null, null);
break;
case "Recycle":
AppPool.InvokeMethod("Recycle", null, null);
break;
}
}
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.ToString());
}
If I stop my application pool it works, but I get a bunch of errors on the server:
-----
The root\MicrosoftIISv2 namespace is marked with the RequiresEncryption flag.
Access to this namespace might be denied if the script or application does not have the
appropriate authentication level. Change the authentication level to Pkt_Privacy
and run the script or application again.
-----
-----
An unhandled exception occurred and the process was terminated.
Application ID: DefaultDomain
Process ID: 1640
Exception: System.AppDomainUnloadedException
Message: Attempted to access an unloaded AppDomain.
StackTrace:
-----
-----
Application: w3wp.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Configuration.ConfigurationErrorsException
Stack:
at System.Diagnostics.TraceUtils.GetRuntimeObject(System.String, System.Type, System.String)
-----
-----
Faulting application name: w3wp.exe, version: 7.5.7601.17514, time stamp: 0x4ce7a5f8
Faulting module name: KERNELBASE.dll, version: 6.1.7601.18409, time stamp: 0x53159a86
Exception code: 0xe0434352
Fault offset: 0x0000c42d
Faulting process id: 0x668
Faulting application start time: 0x01d194020cab3c08
Faulting application path: C:\Windows\SysWOW64\inetsrv\w3wp.exe
Faulting module path: C:\Windows\syswow64\KERNELBASE.dll
Report Id: 57bb8e2a-fff5-11e5-8ddc-005056a330b1
-----
I'm pretty sure that I shouldn't be getting these errors because if I manually (vs programmatically) start/stop the application pool I don't get these warnings or errors.
Can anyone help me understand why I'm getting these errors. I am setting Packet_Privacy I think so that warning doesn't make sense to me.
Thanks
Brad
Related
I want to download a ZIP file from Sitefinity CMS Export / Import menu, but after I clicked "Export to ZIP file" button I've got this error: Data have not been successfully exported. I've tried to export each item individually, but the result was still the same.
Steps to reproduce:
Go to Sitefinity CMS (Admin site) -> Administration -> Export / Import -> Download ZIP file -> select just 1 item -> click "Export to Zip file" button -> the error appears on the Browser: Data have not been
successfully exported.
Detail error message,
On the CMS: Data have not been successfully exported
On the Chrome DevTools:
Response Code 500. ErrorCode: InvalidOperationException. Message: Scheduling is not enabled
The Error.log from App_Data/sitefinity/Logs:
----------------------------------------
ActivityId: 55XXX // obscured info
Timestamp: 11/11/2020 4:44:49 AM
Message: HandlingInstanceID: d9XXX // obscured info
An exception of type 'System.InvalidOperationException' occurred and was caught.
--------------------------------------------------------------------------------
11/11/2020 04:44:49
Type : System.InvalidOperationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=XXX // obscured info
Message : Scheduling is not enabled
Source : Telerik.Sitefinity.Packaging
Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : Void ScheduleTask(Telerik.Sitefinity.Scheduling.ScheduledTask)
HResult : -2146233079
Stack Trace : at Telerik.Sitefinity.Packaging.Web.Services.PackagingWebService.ScheduleTask(ScheduledTask task)
at ServiceStack.Host.ServiceExec`1.<>c__DisplayClass3_0.<CreateExecFn>b__0(Object service, Object request) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Host\ServiceExec.cs:line 132
at ServiceStack.Host.ServiceRunner`1.<ExecuteAsync>d__15.MoveNext() in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Host\ServiceRunner.cs:line 133
Additional Info:
MachineName : XXX // obscured info
TimeStamp : 11/11/2020 4:44:49 AM
FullName : Telerik.Sitefinity.Utilities, Version=13.0.7326.0, Culture=neutral, PublicKeyToken=XXX // obscured info
AppDomainName : /LM/W3SVC/XXX // obscured info
ThreadIdentity : a#b.com // obscured info
WindowsIdentity : IIS APPPOOL\XXX // obscured info
Requested URL : [h-t-t-p-s://]www.XXX.com/RestApi/Sitefinity/packaging/archive // obscured info
Category: ErrorLog
Priority: 0
EventId: 90000
Severity: Error
Title:Enterprise Library Exception Handling
Machine: XXX // obscured info
App Domain: XXX // obscured info
ProcessId: XXX // obscured info
Process Name: D:\Windows\system32\inetsrv\w3wp.exe
Thread Name:
Win32 ThreadId:XXX // obscured info
Extended Properties:
----------------------------------------
Please give me a clue, how to solve this error? I've done research a bit and I get this link: [h-t-t-p-s://]www.progress.com/documentation/sitefinity-cms/for-developers-scheduled-tasks
Go to Administration > Modules and Services and make sure the Scheduling service is activated.
When calling OpenSubKey Registry function from the C# application, getting the below exception and because of this application is not launching.
Application: EMR.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.Security.SecurityException at System.ThrowHelper.ThrowSecurityException(System.ExceptionResource) at Microsoft.Win32.RegistryKey.OpenSubKey(System.String, Boolean)
Below is the Registry key value passing into the openSubkey
HKEY_LOCAL_MACHINE\SOFTWARE\EMR\4.01.00\Technical Data
And one more thing is, after installation first time I am able to launch the application. But Once restart the machine then when trying to launch I am seeing this error.
Below is the code snippet:
public RegistryKey GetRegKeyHandle(String key)
{
key = BASE_REG_KEY + "\\" + key;
if (MainFrame.GetUIControlObject().MGDIsAdmin())
{
MessageBox.Show("Entered to MGDIsAdmin");
regWritable = true;
RegistryKey rkTest = Registry.LocalMachine.OpenSubKey(key, true);
return rkTest;
}
else
{
return Registry.LocalMachine.OpenSubKey(key);
}
}
Please help me why it is throwing security exception only after restart?
I'm trying to use the UWP Windows.Data.Pdf API from a WPF-Desktop app. It can render a PDF page to a PNG image just fine.
The issue I have is that after executing the PDF rendering, closing the WPF-Window does no longer exit the application. The process keeps running. I tried pausing the application in the debugger in this state, but no application code appears to be running. Some thread or resource must still be open, I guess.
My question here is does anybody have any idea why this happens? And furthermore, how can I debug this kind of issue?
The issue is reproducible with the empty WPF template in VS17, I added to the .csproj:
<TargetPlatformVersion>10.0.16299.0</TargetPlatformVersion>
...
<Reference Include="System.Runtime.WindowsRuntime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.dll</HintPath>
</Reference>
<Reference Include="Windows">
<HintPath>$(MSBuildProgramFiles32)\Windows Kits\10\UnionMetadata\10.0.16299.0\Windows.winmd</HintPath>
</Reference>
From a simple button I'm executing this code:
using System;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks;
using Windows.Data.Pdf;
using Windows.Graphics.Imaging;
using Windows.Storage;
using Windows.Storage.Streams;
...
var filename = #"C:\Users\...\a.pdf"
var f = await StorageFile.GetFileFromPathAsync(filename);
byte[] content;
using (var stream = await f.OpenReadAsync())
{
var d = await PdfDocument.LoadFromStreamAsync(stream);
using (var page0 = d.GetPage(0))
{
await page0.PreparePageAsync();
using (var randomAccessStream = new InMemoryRandomAccessStream())
{
await page0.RenderToStreamAsync(randomAccessStream, new PdfPageRenderOptions { BitmapEncoderId = BitmapEncoder.PngEncoderId });
content = new byte[randomAccessStream.Size];
await randomAccessStream.ReadAsync(content.AsBuffer(), (uint)randomAccessStream.Size, InputStreamOptions.None);
}
}
}
File.WriteAllBytes(#"C:\Users\...\b.png", content);
This is almost the entire code, but in case I missed something I also pushed it to https://github.com/marv51/PDFRendererNotExiting
Thank you very much in advance for any help on this.
Update:
I just observed, that the process does eventually exit after about 2 minutes!
Probably related, I found in the event viewer:
Faulting application name: WpfApp3.exe, version: 1.0.0.0, time stamp: 0x5b291e3a
Faulting module name: ntdll.dll, version: 10.0.17134.1000, time stamp: 0xcfe5bd82
Exception code: 0xc0000005
Fault offset: 0x000420c8
Faulting process id: 0x1ee0
Faulting application start time: 0x01d407e07f1c3295
Faulting application path: C:\Users\ruehe\source\repos\WpfApp3\WpfApp3\bin\Release\WpfApp3.exe
Faulting module path: C:\WINDOWS\SYSTEM32\ntdll.dll
Report Id: 3a51f5ff-52b3-47fb-b00d-bf002f932c41
Faulting package full name:
Faulting package-relative application ID:
So I assume some background thread crashed during termination and Windows Error Reporting keeps the process alive to collect information. Or some kind of timeout kills open resources?
I'm sorry, I just found this. Can I do anything with this crash Information?
Update 2
After spending a lot of time on this and learning some windbg, I think this might be an Nvidia graphics driver crash:
Attaching to the app and then closing the window shows this exception:
(2134.1cac): Unknown exception - code 0000071a (first chance)
(2134.1cac): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\WINDOWS\System32\DriverStore\FileRepository\nv_dispi.inf_amd64_040c7acb04cee565\nvwgf2um.dll -
eax=00000000 ebx=0be09f10 ecx=00000013 edx=00000000 esi=00000000 edi=00000030
eip=779f38e8 esp=007decd0 ebp=007ded10 iopl=0 nv up ei pl zr na pe nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00210246
ntdll!RtlFreeHeap+0x28:
779f38e8 817e08eeddeedd cmp dword ptr [esi+8],0DDEEDDEEh ds:002b:00000008=????????
I posted the analyze -v output here: https://gist.github.com/Marv51/d3ad0e9a49b6c985d9116600fd0475b7
From looking at the stacktrace I believe the destructor for the internal class Windows.Data.Pdf.CPdfStatics tries to release some DirectX resources and the Nvidia driver corrupts the heap during this process.
I tried updating to the latest Nvidia driver, which changed nothing.
Not sure where I can go from here. I'm still a windbg beginner, so I might interpret this output wrong.
Maybe the 'solution' for now is that I will do this work in an external process to avoid these issues from 'infecting' the main app.
I'm trying to collect the Windows Mobile 10 calls history by using the latest API. I have enabled all possible capabilities for my application, but still I'm getting "Access Denied" error while running this code:
var operation = PhoneCallHistoryManager.RequestStoreAsync(PhoneCallHistoryStoreAccessType.AppEntriesReadWrite);
operation.Completed = (o, ev) =>
{
PhoneCallHistoryStore store = o.GetResults();
PhoneCallHistoryEntryReader reader = store.GetEntryReader();
var operation2 = reader.ReadBatchAsync();
operation2.Completed = (o2, ev2) =>
{
IReadOnlyList<PhoneCallHistoryEntry> callsList = o2.GetResults();
foreach (PhoneCallHistoryEntry entry in callsList)
{
// process calls here
}
};
};
I'm getting the following error message while doing line 4:
An exception of type 'System.UnauthorizedAccessException' occurred in App1.exe but was not handled in user code
Additional information: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
I'm running this code on Mobile Emulator in Visual Studio 2015.
This is what I used for that code:
https://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.calls.aspx
Any idea what can be wrong?
In order to make above code working and view phone call history, need to add the following things:
1) Rescap namespace
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
2) Restricted capability "phoneCallHistory"
<rescap:Capability Name="phoneCallHistory"/>
3) Change PhoneCallHistoryAccessType to AllEntriesLimitedReadAndWrite.
var operation = PhoneCallHistoryManager.RequestStoreAsync(PhoneCallHistoryStoreAccessType.AllEntriesLimitedReadWrite);
Thanks to #RaymondChen for giving me the proper capability name.
I start use Selenium.WebDriver (v2.45) to run visual tests.
As web driver I use FirefoxDriver. I have installed Firefox 38. When I try run test firefox return exception with message:
FF has stopped working.
Does anyone have any suggestions? It worked in previous week, is it possible that my test was crashed by updated?
Problem signature:
Problem Event Name: APPCRASH
Application Name: Firefox.exe
Application Version: 38.0.1.5611
Application Timestamp: 55540a1a
Fault Module Name: xul.dll
Fault Module Version: 38.0.1.5611
Fault Module Timestamp: 55541969
Exception Code: c0000005
Exception Offset: 0035669b
OS Version: 6.3.9600.2.0.0.16.7
Locale ID: 1033
Additional Information 1: 5861
Additional Information 2: 5861822e1919d7c014bbb064c64908b2
Additional Information 3: a10f
Additional Information 4: a10ff7d2bb2516fdc753f9c34fc3b069
There is my test method body:
[Fact]
public void ShouldLoginForTestAccount()
{
var driver = new FirefoxDriver();
driver.Manage().Cookies.DeleteAllCookies();
driver.Navigate().GoToUrl(LoginPage);
driver.FindElementById("Login")
.SendKeys("correctLogin");
driver.FindElementById("Password")
.SendKeys("correctPassword");
driver.FindElementByTagName("button")
.Click();
Assert.Equal(TestingProjectUrl, driver.Url);
driver.Close();
}
Selenium 2.45 does not reliably work with Firefox 38 due to compatibility issues.
Downgrade Firefox to 35 (link to 35.0.1).
I have a suggestion.
I was getting the error bellow when I called Quit() method of WebDriver.
unknown software exception (0x80000003) em 0x55fdec79
So I created the WebDriver as follow:
FirefoxOptions foxOptions = new FirefoxOptions();
foxOptions.SetPreference("dom.allow_scripts_to_close_windows", true);
driver = new ThreadLocal<IWebDriver>(() => { return new FirefoxDriver(service as FirefoxDriverService, foxOptions, new TimeSpan(0, 1, 0)); }).Value;
Then, before call Quit() method, I execute one javascript to close the main window:
try { ((IJavaScriptExecutor)driver).ExecuteScript("window.close();"); } catch { }
So now I'm able to call Quit() without get any error. I know that this is a workaround, but I think this can help you.