Google Analytics İzleme

15 Kasım 2019

wpf - Windows'ta Program Files'a kurulan uygulamanın text dosyaya yazma durumu

Wpf windows uygulamasını Setup yapıp, işletim sisteminin Program Files klasorune kurulumunu sağladık. Uygulamada loglama ve ayar bilgilerini text dosyaya yazma işlevleri bulunuyor. Loglama yapılan text dosyası Program Files içinde ilgili uygulama klasorunde değil de
"C:\Users\MyUser \AppData\Local\VirtualStore\Program Files\MyApps\Logs\Log.txt" şeklinde farklı bir yolda olduğunu gördük.
Bunun nedeni Windows'ta bulunan UAC virtualization işleviymiş. Bundan dolayı program ana kurulum klasorunu C:\ ana dizini altına ilgili program klasoru olarak ayarladık. Uygulama klasoru altında loglama dosyalarının yazılmasını sağladık.

--
UAC Virtualization
By default, UAC virtualizes requests for protected resources to provide compatibility with applications not developed for UAC. This is important because many applications written for Windows XP and earlier operating systems assume that the user has administrative privileges and attempt to write to protected resources such as the Program Files or System folders.

UAC virtualization redirects requests for the following resources to safer, user-specific locations:

%Program Files%
%WinDir%
%WinDir%\System32
HKEY_LOCAL_MACHINE\Software

When a user process attempts to add a file to a protected folder, UAC redirects the request to the \AppData\Local\VirtualStore\ folder in the user's profile. For example, if a user named MyUser runs an application that stores a log file at C:\Program Files\MyApps\Logs\Log.txt, the file write attempt will succeed. However, UAC will actually store the file at C:\Users\MyUser \AppData\Local\VirtualStore\Program Files\MyApps\Logs\Log.txt. The application will be able to access the file at C:\Program Files\MyApps\Logs\Log.txt, but the user will need to browse to her profile to access the file directly, because virtualization affects only the application process itself. In other words, if the user browses to open the log file from within the application, it will appear to be under %Program Files%. If the user browses to open the log file using a Windows Explorer window, it will be under her profile.
--
https://sourcedaddy.com/windows-7/uac-virtualization.html

--
User Account Control Data Redirection
Today, many applications are still designed to write files to the Program Files, Windows directories, or system root (typically the C drive) folders.

Virtualization is intended only to assist in application compatibility with existing programs. New applications designed for Microsoft Windows 7 should NOT perform write operations to sensitive system areas, nor should they rely on virtualization to provide redress for incorrect application behavior. Always develop applications for use with standard user privileges and don’t count on the application running under administrator privileges. Test your application with standard user privileges and not administrator privileges.

If you are experiencing UAC virtualization with applications developed prior to Windows 7, re-design your applications to write files to the appropriate locations.
--
https://stackoverflow.com/questions/20570754/get-real-path-of-a-log-file-stored-in-virtualstore/43246153

--
In your case, log files should either be stored:

in the per-user LocalAppData folder (typically resolves to C:\Users\Sugrue\AppData\Local)
in the CommonAppData folder (typically resolves to C:\ProgramData)
--



30 Temmuz 2019

asp.net core 2.2 - HTTP Error 502.5 - ANCM Out-Of-Process Startup Failure hatası

Asp.net Core MVC 2.2 sürümünde geliştirilen web uygulamasını Windows Server 2012 R2 sunucusunda IIS altında kurulum yaptım.

- 205 portuna tanımlı olacak şekilde temel iis web sitesi kurulum adımlarını uyguluyoruz.
- Sitenin bağlandığı App Pool'da .Net CLR versiyon tanımını "No Managed Code" seçiyoruz.
- ASP.NET Core/.NET Core: Runtime & Hosting Bundle 2.2.6 sürümünü kuruyoruz.
- IIS servisini kapa ve aç yapıyoruz.

http://localhost:205/ şeklinde siteyi çağırınca aşağıdaki gibi hata verdi.

Site açıldığında ekranda "HTTP Error 502.5 - ANCM Out-Of-Process Startup Failure" şeklinde hata mesajı verdi.
 
Bu durumu düzeltmek için; yönetici yetkisiyle cmd komut satırında iki komutu sırayla çalıştırdım ve düzeldi.

> net stop was /y
> net start w3svc

Tekrar web uygulamasını çağırdığımızda hata vermeden başarıyla çalıştı.

Kaynaklar:
https://stackoverflow.com/questions/54755562/http-error-502-5-ancm-out-of-process-startup-failure-after-upgrading-to-asp-ne
https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-2.2