Using lock in C#

Sometimes when we are using threading in a project and there are simultaneous threads running a piece of code but you want the threads to run the code sequentially,then we can make use of lock and create an object and place the critical section code in this lock.

private static readonly Object _lock = new Object(); lock (_lock) { // critical section }
Code language: JavaScript (javascript)

Visual Studio 2017, The breakpoint will not currently be hit. No symbols have been loaded for this document

I was working in a project where we use slow cheetah and have different configuration files for different environments and when trying to debug using a “local-dev” configuration i was having the above mentioned error.
This configuration was added recently, with other configuration the breakpoint was hitting and working normally.

With the help of stackoverflow I tried some changes and after the follwing changes were made I was able to hit the breakpoint and resolve the issue.

  • Right click on the project and go to properties and then to Debug tab. Make sure you have the above settings. “Define DEBUG constant” and “Define TRACE constant” are selected.
  • After that select Advanced and make sure you have the above Settings.
  • Save and then rebuild the solution,you will be able to resolve the issue.

For those who might be wondering what slow cheetah is ?? It is a visual studio extension that transform our config files. We were using this to use config files based on the environment like Dev,QA,Prod,Local-Dev. You can find more details below

https://marketplace.visualstudio.com/items?itemName=vscps.SlowCheetah-XMLTransforms

Windows Service Errors and solutions

Have you ever seen this error when trying to start a windows service

The Renkim File Service service is not started.

More help is available by typing NET HELPMSG 3521.

I had trouble resolving this issue. For me the issue was  the service was expecting a connection to database and in anothe case it was trying to connect to Rabbit Mq queue.

 

So please make sure the requirements for your service running conditions are satisfied before trying to start your service.

 

RabbitMQ Installation and Using Management Interface

  • To Install RabbitMQ you need to install Erlang first. Download and install the Erlang OTP latest version.
  • After that install the RabbitMQ .
  • Once RabbitMQ is installed browse to the location where it is installed in the program files like below.
  • Now enable the management interface plugin using the command
    “rabbitmq-plugins.bat enable rabbitmq_management”
  • Now restart the rabbitMQ service.
  • After that you can visit the url “http://localhost:15672” and login using credentials guest for both username and password.
  • After the login you can see all the details like below.

Adding more than one object to a list

I was adding result of a query which return a list of files but i was having error “The best overloaded method has some invalid arguments”.

I was adding elements using .Add() method and it was causing the error.  Add() method is used only to add single object, when we want to add multiple objects we should use AddRange() method, my error got resolved with this.

 

Hosting multiple domains using Hostgator baby account

With hostagator baby plan you have the ability to host unlimited domains. There will be a primary domain name associated with the hosting account and to add new domain to host using the existing account follow the below steps.

  1. First buy the domain you require from any of the places like hostgator,godaddy,nameocheap etc.
  2. Once you bought the domain you need to add this domain to your  hosting account.
  3. Please login to the cpanel and under domains you will find add domain,click on that and you will land on a new page.
  4. In the new page fill out the domain name and choose the directory, by default it will be home/’domain name’.
  5. Also select the create ftp account and it will prompt for a password. Provide a password to use for this account.
  6. After that click on add domain. This completes the addition of domain to your account.
  7. Now under the domains section you will see the daomain but it will display “provisioning in progress”. We have to wait 24 to 36 hours till this step is done.
  8. Once done when we go to the domian name it will say configure the dns name servers. By default the name servers will point to hostgator name servers.
  9. We have the provide the dns name servers associated with our hosting account. Once this is done we will be able to use the domain name and build a websote or webapp and host it on the url.

Happy hosting !!!