Tuesday, June 25, 2013

Sync to ancestors properties


<Canvas>

  <DockPanel
      Width="{Binding RelativeSource=
                {RelativeSource FindAncestor,
                AncestorType={x:Type Canvas}},
                Path=ActualWidth}"
      Height="{Binding RelativeSource=
                {RelativeSource FindAncestor,
                AncestorType={x:Type Canvas}},
                Path=ActualHeight}">
  </DockPanel>
</Canvas>

Window Service - Pointers and troubles encountered.

AppDomain.CurrentDomain.BaseDirectory - To have a path same as the service location.
----------------------------------------
Add debug mode in win service
     #if DEBUG #else #end
----------------------------------------
Install Manually
Right click window service and add install

  • click serviceProcessInstaller and go to properties
    1. change account property : LocalService for local and LocalSystem for server

  • click serviceInstaller and go to properties
    1. start type - automatic
    2. update service name and description to project name
Go to developer cmd: run as ADMINISTRATOR
Create batch files
  • InstallUtil ServiceName.exe
  • InstallUtil /u ServiceName
C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe

Right click service and select recovery
----------------------------------------
Error encountered 1
System.ComponentModel.Win32Exception: The specified service already exists serviceInstaller.DisplayName = "A new name";

  • sc delete YourServiceName

Error encountered 2
Error 1053: The service did not respond to the start or control request in a timely fashion framework version problem 2008 r2
----------------------------------------
Error Handling
Add another thread to catch the error
catch (Exception exception)
            {
                System.Threading.ThreadPool.QueueUserWorkItem(
                    _ => { _logger.Error("", exception.Message, "", "", exception.StackTrace); });              
                    //_ => { throw new Exception("Exception on timer.", exception); });              
            }

----------------------------------------
Setup same framework

Check Windows Event, Windows Logs, System
----------------------------------------
Helpfull Links
http://stackoverflow.com/questions/14121079/windows-could-not-start-service-on-win-server-2008-r2-sp1-error-1053
http://www.coretechnologies.com/products/AlwaysUp/Apps/RunCommandPromptAsAService.html

----------------------------------------
Install Automatically manually

Add a new project