Search this blog

You can search for all the topics in our blog using our google custom search now.

Search the blog

Loading

Sunday, July 25, 2010

How to create setup installer for windows service

Incase you haven't seen the previous tutorial, then below is the link:

How to create a windows service



Once we are done with creating a windows service, we need to install the windows service using one of the two options: one is using InstallUtil.exe tool or using a setup.In the videos below we will see how to create a setup project and create setup installer for our windows services.





Regards
Sameer Shaik

How to create a windows service

Free Microsoft MCTS 70-536 Examination Training and Preparation for Jobs





Window services are applications which run in background with no user interaction.We can create these services for many purposes like tracking the changes done to the files in a particular folder for example.In our example, we will be creating a windows service, which will create a text document at certain location on our local computer and writes the status of our service along with the time stamp.



Below is the code for the same.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.IO;

namespace WsEg1
{
public partial class Service1 : ServiceBase
{
public Service1()
{
InitializeComponent();
}

protected override void OnStart(string[] args)
{
FileStream fs = new FileStream(@"C:\My stuff\Work Stuff\Pdf\ServiceInfo.txt", FileMode.OpenOrCreate);
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine("Service has been started at " + System.DateTime.Now);
sw.Close();
fs.Close();
}

protected override void OnStop()
{
FileStream fs = new FileStream(@"C:\My stuff\Work Stuff\Pdf\ServiceInfo.txt", FileMode.OpenOrCreate);
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine("Service has been stopped at " + System.DateTime.Now);
sw.Close();
fs.Close();
}
}
}

After creating windows service we will add an installer to the project which will have the configuration information of our windows service.To know how you can an installer to a windows service, please check the video.
Regards
Sameer Shaik

Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net, study guide, sample questions, Exam Prep, Exam Practice Test

Saturday, July 24, 2010

Application Domain Tutorial Part 3

APPLYING HOST EVIDENCE TO AN APPLICATION DOMAIN:

If you haven't gone through my previous tutorial then please do, below are the links:


Free Microsoft MCTS 70-536 Examination Training and Preparation for Jobs

Application Domain Tutorial Part 2

As we have seen that we can restrict  access to any resource for an assembly. Now what if you want to provide some access privileges and restrict some access privileges for an application domain? How would you do it? Answer is quite simple, you do it the same way you did for an assembly.First create a host evidence object array and then create EVIDENCE for the application domain. You can pass the EVIDENCE as a parameter to CreateDomain Method.

I will upload a video on this post soon.
Meanwhile, below is the code for creating an application domain with configured access privileges and with custom properties set.

Watch the video to learn how to configure application domain:



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Policy;


namespace AppdomainEx1
{
    class Program
    {
        static void Main(string[] args)
        {
            object[] hEvidence = {new Zone(System.Security.SecurityZone.MyComputer) };
            Evidence AppEvidence = new Evidence(hEvidence,null);
            AppDomainSetup setup = new AppDomainSetup();
            setup.ApplicationBase = System.Environment.CurrentDirectory;
            setup.DisallowCodeDownload = false;
            setup.DisallowBindingRedirects = false;

            setup.ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;

            AppDomain d = AppDomain.CreateDomain("HelloWorldDomain",AppEvidence,setup);
            //d.ExecuteAssembly(@"C:\Users\Owner\Documents\Visual Studio 2008\Projects\HelloWorld\HelloWorld\bin\Debug\HelloWorld.exe");
           d.ExecuteAssemblyByName("HelloWorld");
           Console.WriteLine("\n");
            Console.WriteLine(setup.ApplicationBase);
            Console.ReadKey();
            AppDomain.Unload(d);
        }
    }
}



Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net.



Friday, July 23, 2010

Application Domain Tutorial Part 2

If you haven't gone through my previous tutorial then please do, below is the link:

Application Domain Tutorial Part 1

CONFIGURING APPLICATION DOMAINS
------------------------------------------------

We need configure application domains to create customized environments for the assemblies.If you run an assembly with full trust access then one: There is no point of running that assembly in an application domain and Two: Your application domain becomes vulnerable for any security risks.

So one way to limit access privileges to the assemblies is by using EVIDENCE. Evidence is the access privileges information of the assembly which is gathered by runtime.You need add System.Security.Policy namespace to be able to create Evidence for an assembly.In our previous example we ran an assembly in an application domain using ExecuteAssembly Method.Now in this example, we will use ExecuteAssemblyByName method to run an assembly with access privileges limited to local computer.Remember you can do the same using ExecuteAssembly Method as well.

Watch this video from here:




To be continued in next video.



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Policy;


namespace AppdomainEx1
{
    class Program
    {
        static void Main(string[] args)
        {
            object[] hEvidence = {new Zone(System.Security.SecurityZone.MyComputer) };
            Evidence AppEvidence = new Evidence(hEvidence,null);
            AppDomain d = AppDomain.CreateDomain("HelloWorldDomain");
  
            d.ExecuteAssemblyByName("HelloWorld",AppEvidence);
            AppDomain.Unload(d);
        }
    }
}

Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net.

Wednesday, July 21, 2010

Application Domain Tutorial Part 1

CREATING APPLICATION DOMAINS
--------------------------------------------

Video tutorial part-1




Video tutorial part-2




Application Domain:

An application domain is a logical container that allows multiple assemblies to run within a single process.Each application domain can be configured with different security access levels.

In our example we will create a simple application and then we will try to run this application within a domain that we will create.So first create an application and then we will create an application domain.
First create a hello world application like this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("This is a hello world application running an application domain");
Console.ReadKey();
}
}
}

Once you created an application.You can run this application under a particular domain. In our example we will start another console application and create an application domain. We can run any application or assemblies by providing the path of assembly/exe file in ExecuteAssembly Method as follows:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Policy;


namespace AppdomainEx1
{
    class Program
    {
        static void Main(string[] args)
        {
        


            AppDomain d = AppDomain.CreateDomain("HelloWorldDomain");
            d.ExecuteAssembly(@"C:\Users\Owner\Documents\Visual Studio 2008\Projects\HelloWorld\HelloWorld\bin\Debug\HelloWorld.exe");
        
            AppDomain.Unload(d);
        }
    }
}


Will be uploading the video tutorials on this in a while.

Regards
Sameer Shaik

Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net.

Sunday, July 4, 2010

Learning regular expression step by step tutorials: Step 5


Free Microsoft MCTS 70-536 Examination Training and Preparation for Jobs






ANCHORS
First thing to remember is that anchors doesn't match with anything. They are not available  to match with any characters but to specify to match a position before,between or after characters.They are called anchors since they provide the information of a position of match to be checked. Start of a string anchor is denoted by caret(^) symbol and End of a string is denoted by dollar($) symbol. ^ matches with first character in the string and $ matches with last character of string.

When Using Multi-Lines:

 In practicality we have strings with multiple lines for example you are reading from a file.
In those cases, we need to explicitly tell the Regex engine to find matches in Multi-Line Mode like this:
 Regex.Match("string", "regex", RegexOptions.Multiline)

There are other anchors which match characters at the beginning and end of the line only. It will not include matches that happens at/after line breaks.They are \A stands for permanent start of string anchor and \Z stands for permanent end of string anchor.



Related Topics Links

Step 1 Learning regular expressions,


Step 2 Learning regular expressions


Step 3 Learning regular expressions


Step 4 Learning regular expressions
Regards
Sameer Shaik
Free Microsoft MCTS 70-536 Examination Training and Preparation for Jobs and Interviews
Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net.

Learning regular expression step by step tutorials: Step 4


Free Microsoft MCTS 70-536 Examination Training and Preparation for Jobs and Interviews



DOT META CHARACTER
In Regular expressions, DOT or PERIOD meta character which is used most commonly. Dot meta character will match with any single character, not checking what character it is except for any new line characters(\n).

The dot will match with anything which is very convenient at the beginning when you test our regular expression with valid input. The drawback is: again dot will match with anything and give us wrong matches.

For example:

Imagine we need to check if a given number is a valid phone number. To do that we can form a regular expression like this:

\d\d\d.\d\d\d.\d\d\d\d

The reason i have given a dot is because the user might enter a phone number like this: 408 512 3625 , 408-512-6589 etc etc.

The above regular expressions works nicely for  above two formats. How ever it also matches for 408551293625,408/512/3625 etc etc.

So use it carefully.

Regards





Related Topics Links

Step 1 Learning regular expressions,


Step 2 Learning regular expressions


Step 3 Learning regular expressions
Sameer Shaik


 Video Links will be posted soon
Free Microsoft MCTS 70-536 Examination Training and Preparation for Jobs and Interviews
Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net.

Thursday, July 1, 2010

Books suggested for MCTS 70-536 examination

I know you would want to make sure that you pass this exam, to be able to do that we all need good resources. I agree.

However i do not think i can suggest you to read a combination of book which can guarantee that you have prepared everything.

These are the resources you will be getting information from:

-> Microsoft .NET Framework 2.0 Application Development Foundation Training Kit, ISBN: 0-7356-2277-9


->MSDN Library


o Microsoft Press: Programming Visual C# 2005: The Language, ISBN: 0-7356-2181-0
or
o Microsoft Press: Programming Visual Basic 2005: The Language, ISBN: 0-7356-2183-7


-> Optional books:
o Microsoft Press: Programming Visual C# 2005: The Base Class Library, ISBN: 0-7356-2308-2
or
o Microsoft Press: Programming Visual Basic 2005: The Base Class Library, ISBN: 0-7356-2308-8
o Microsoft Press: Microsoft Visual C# 2005: Step By Step, ISBN: 0-7356-2129-2
or
o Microsoft Press: Microsoft Visual Basic 2005: Step By Step, ISBN: 0-7356-2131-4


These are resources that can give you complete information.

Best of Luck

Regards
Sameer Shaik