Application Manifest Schema:

Posted by senthil | 12:41:00 AM | , | 0 comments »

Application manifests are not new to the Windows Vista release. Manifests were used in Windows XP to help application developers identify such things as which versions of DLLs the application was tested with. Providing the execution level is an extension to that existing application manifest schema. The Windows Vista application manifest has been enhanced with attributes that permit developers to mark their applications with a requested execution level. The following is the format for this:
<requestedExecutionLevel
level="asInvoker|highestAvailable|requireAdministrator"
uiAccess="true|false"/>
Your application will prompt for elevation if the user is an administrator and UAC is enabled
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
  <security>
   <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
    <!-- UAC Manifest Options
      If you want to change the Windows User Account Control level replace the 
      requestedExecutionLevel node with one of the following.

    <requestedExecutionLevel level="asInvoker" uiAccess="false" />
    <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
    <requestedExecutionLevel level="highestAvailable" uiAccess="false" />

      Specifying requestedExecutionLevel node will disable file and registry virtualization.
      If you want to utilize File and Registry Virtualization for backward 
      compatibility then delete the requestedExecutionLevel node.
    -->
    <requestedExecutionLevel level="highestAvailable" uiAccess="false" />
   </requestedPrivileges>
  </security>
 </trustInfo>
Read more ...

This error i have experienced. when i going to start my application service while happened this error. Just start your service using sample application create one button click and then place this code. Its service start using ServiceController.
private void button1_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ServiceController sc = new ServiceController("YottaMark Code Dispenser");
                if ((sc.Status.Equals(ServiceControllerStatus.Stopped)))
                {
                    sc.Start();

                    MessageBox.Show("Starting the  YottaMark Code Dispenser");
                }
                MessageBox.Show("Started the YottaMark Code Dispenser");
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message);
            }
        }
Read more ...

This code create a new gridview in wpf application. its working good.
<Grid>
        <DataGrid x:Name="MyDataGrid" x:Uid="MyDataGrid" AutoGenerateColumns="False" 
                       AlternationCount="2" SelectionMode="Single" Height="175" VerticalAlignment="Bottom" Background="White" Margin="12,0,12,12" CanUserAddRows="False" CanUserDeleteRows="False">
            <DataGrid.Columns>
                <DataGridTextColumn IsReadOnly="True" Binding="{Binding Path=Name}"
                                    Header="Name" Width="SizeToHeader" />
                <DataGridTextColumn IsReadOnly="True" Binding="{Binding Path=Email}" 
                                    Header="Email" Width="SizeToHeader" />
                <DataGridTextColumn IsReadOnly="True" Binding="{Binding Path=DOB}"
                                    Header="DOB" Width="SizeToHeader" />
                <DataGridTextColumn IsReadOnly="True" Binding="{Binding Path=Address1}"
                                    Header="Address1" Width="SizeToHeader" />
                <DataGridTextColumn IsReadOnly="True" Binding="{Binding Path=City}"
                                    Header="City" Width="SizeToHeader" />
                <DataGridTextColumn IsReadOnly="True" Binding="{Binding Path=Country}"
                                    Header="Country" Width="SizeToHeader" />
                <DataGridTemplateColumn Header="Edit">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button Content="Edit" Click="EditButton_Click" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="Delete">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button Content="Delete" Click="DeleteButton_Click" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>                    
                </DataGridTemplateColumn>               
            </DataGrid.Columns>
        </DataGrid>
        <Label Content="Printer Configuration" FontSize="16" Foreground="Blue" Height="28" HorizontalAlignment="Left" Margin="8,5,0,0" Name="Title" VerticalAlignment="Top" Width="272" />
        <Button Content="Add Printer" Height="23" HorizontalAlignment="Left" Margin="409,12,0,0" Name="btnAddPrinter" VerticalAlignment="Top" Width="141" Background="Blue" Foreground="White" FontSize="13" Click="btnAddEmploy_Click" />
    </Grid>
Just copy this code and past your wpf xaml file side of the window after that
public void LoadEmploys()
        {
string employconfigFolder="D:\\Employ.xml"
            var doc = new XmlDocument();
            doc.Load(employconfigFolder);

            XmlNodeList employ = doc.GetElementsByTagName("Employ");

            List<EmployAttribute> authors = new List<EmployAttribute>();

            foreach (XmlNode item in employ)
            {
                bool defaultPrinter = false;

                authors.Add(new PrinterAttribute()
                {
                    Name = item.Attributes["Name"].Value,
                    Email = item.Attributes["Email"].Value,
                    DOB = item.Attributes["DOB"].Value,
                    Address1 = item.Attributes["Address1"].Value,
                    City = item.Attributes["City"].Value,
                    Country = item.Attributes["Country"].Value,
                });
            }
            MyDataGrid.ItemsSource = authors;
        }



 public class EmployAttribute
        {
            public string Name { get; set; }
            public string Email { get; set; }
            public string DOB { get; set; }
            public string Address1 { get; set; }
            public bool City { get; set; }
            public bool Country { get; set; }
        }
you can call LoadEmploys() method in your window_Loaded() its working fine.
Read more ...

How to method call using Timer in c#

Posted by senthil | 12:09:00 PM | | 0 comments »

this code using the system timer we can call the method. i tried working good. its a easy way to call the method using Timer interval time. Following the sample code:
private void button1_Click(object sender, RoutedEventArgs e)
        {
            aTimer = new System.Timers.Timer(10000);

            aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);

            aTimer.Interval = 2000;
            aTimer.Enabled = true;

            Console.WriteLine("Press the Enter key to exit the program.");
            Console.ReadLine();
           
        }

        private static void OnTimedEvent(object source, ElapsedEventArgs e)
        {
            aTimer.Enabled = false;
            Console.WriteLine("The Elapsed event was raised at {0}", e.SignalTime);
        }
Read more ...

Related Posts Plugin for WordPress, Blogger...