MongoDB Installation Procedure

Today this post will help you to install MongoDB in Windows 32 bit environment.

  • Just download the required mongodb installation package or .msi from Official MongoDB site where you will get the latest version.
  • Then manually create db folder in c:\ drive like

    C:\data:\db

  • Go to mongodb installed path from there you open command prompt then type

    C:\Program Files\MongoDB\Server\3.2\bin>mongod

  • if successful then there you can find

    I NETWORK  [initandlisten] waiting for connections on port 27017

  • if you face anything kind of issues like “Exception initAndListen” and MongoDB can not start server… then you can do as given below instructions.
  • C:\Program Files\MongoDB\Server\3.2\bin>mongod –storageEngine=mmapv1  –dbpath C:\data\db

    The above line depicts to map the db folder.

  • Yay. Then there you can go!!! Finally you will get the “waiting for connections message”.
  • If you want to see your available databases in locally, then  use the below command by keep opening the already existing command prompt.
  • C:\Users\srini>mongo                                                                                                             Message will be :  MongoDB shell version: 3.2.3                                                                                                      connecting to: test                                                                                                                          Welcome to the MongoDB shell.

  • Again if you face issue like “mongo” is not recognized as an external or internal command, then time to set the Environment variable to Path.
  • Go to Control Panel -> System and Security – > Advanced Settings-> Environment Variable-> select Path and Edit to add

  • “;C:\Program Files\MongoDB\Server\3.2\bin\”   click ok.

  • Now try you can get the MongoDB Shell version Message…

That’s it guys.

Hope it helped you. Thank you.

Share your comments.

Enabling Visual Studio Browser Link

In Visual studio 2013, When you work on design pages (html) closely with Browser, you might experience “Browser Link” feature is not working.

Use of Browser Link,

  • List out all the connected browsers
  • Without going to browser for every time to see the changes to Html page, simply “Ctrl+Alt+Enter” will do refresh work for you by simply being in visual studio itself.

This post will help you to enable “Browser Link” Feature in Visual Studio 2013.

By default, Browser link will be enabled by including the below script line at end of <body></body> 

  • (/_vwd/js/artery) and make sure that appsettings for browser link is set to true.

<appSettings>
<!–Enabling Browser Link–>
<add key=”vs:EnableBrowserLink” value=”true”/>
</appSettings>

  • Static HTML pages can be linked by adding
    <modules runAllManagedModulesForAllRequests=”true”/>
  • Final thing is keep in mind that before debugging just ensure that
    <compilation debug=”true”/> is set to true.

Yay!!! That’s it. There we go.

Open Visual Studio Specific version in Run Command

If the devenv.exe is associated with earlier version of visual studio, now you wish to change it to newer version of visual studio then just follow the below steps to achieve it.

  • Click Windows key + r
  • Type Regedit.exe
  • Navigate to HKEY_LOCAL_MACHINE-> Software->Microsoft->Windows->Current Version->App Paths->devenv.exe
  • Click on Default item to modify.
  • Grab the specific version of visual studio devenv.exe path you wished to open, then just replace this with already existing value for Data column
  • Once done, try to open Windows Key+r
  • Type devenv.exe , Yay!!! We got it.

 

Hope it helps you. Share your comments.

Ways are to wiring to an Event

Tags

,

4 different ways are there to link Event handler to Event

1. Creating new delegate instance of our custom delegate

Eg:

public delegate int CalculateTotal(int x, int y);
public class OfferNumber
{
 public event CalculateTotal totalDelegate;
}
public class EventSampleNewDelegateInstanceCreation
{
 public void DelegateAccess()
 {
 OfferNumber number = new OfferNumber();
//Example for NewDelegateInstanceCreation
 number.totalDelegate += new CalculateTotal(sample);
 }
private int sample(int x, int y)
 {
 throw new NotImplementedException();
 }
}
2. Using Delegate Inference,
Eg:
 public class EventSampleDelegateInference
 {
 public void DelegateAccess()
 {
 OfferNumber number = new OfferNumber();
//Example for Delegate Inference
 number.totalDelegate += number_totalDelegate;
 }
int number_totalDelegate(int x, int y)
 {
 throw new NotImplementedException();
 }
 }

3. Using anonymous delegate,

Eg:
public class EventSampleAnonymousDelegate
 {
 public void DelegateAccess()
 {
 OfferNumber number = new OfferNumber();
//Example for Anonymous Delegate
 number.totalDelegate += delegate(int x, int y)
 {
 return x + y;
 };
 }
 }
4. Using Lamda Expression,
Eg:
public class EventSampleLamdaExpression
 {
 public void DelegateAccess()
 {
 OfferNumber number = new OfferNumber();
 //Example for using Lamda Expression
 number.totalDelegate += (x, y) =>
 {
 return x + y;
 };
 }
 }

Default, Optional & Named Parameters Usage

Tags

, ,

1. In modern days, using default/optional/naming parameters we can use method overloading concept. Really interesting one. It reduces long list of methods in our code file if we go for earlier method overloading concept.

2. Required parameters should be placed before the optional parameters in the method definition and method calling. Else we get compiler error.
#right way (FIG : I)

private void Super(int calculatedPoints,string status=”success”)
{

}

Here, calculatedPoints is the required parameter and status is the optional parameter. you can not define the method like below

#Wrong way

private void Super(string status=”success”, int calculatedPoints)
{

}

Eg:

private void Super(string one=”Srini”,string two=”Nice”)
{

}

I would like to give you quick explanation about Default/Optional/Naming parameters. Let’s get into that.

Default Parameters

If we call the below method, output will be

* Super();   // srini and Nice will be taken as values.

Named parameters

* When you have multiple number of same data types passing to the method, Make sure to specify the parameter name along with value, like below

Super(one:”self”,two:”confidence”); //If you didn’t specify the “one” parameter, the complier will get confused to which of the parameter that value to be passed.

If your method don’t have same data types, then you just simply pass the value. that’s enough.

Optional Parameters

* Super(one:”Self”); you can call the method without passing the value for another parameter, two will have the value as default “Nice“.