Wednesday, May 14, 2014

Useful PowerShell Commands

1) Command to get PowerShell Version:
                         
$PSVersionTable.PSVersion


2) Command to get the current directory of the PowerShell Script:

a)  In PowerShell 3.0

$PSScriptRoot


b) In PowerShell 2.0

$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition


3) Read xml file into PowerShell

$xmlFilePath = "C:\SampleXmlFile.xml"

[xml]$xmlFileContents = Get-Content $xmlFilePath

 

Sunday, June 24, 2012

Handling Session Error in Multiple Front End Servers in Asp.Net 4.0

Perform the following steps to handle Session for Multiple Front End Servers

1) Add the tag under tag in the web.config file of all the front end servers

For Example:
<sessionState mode="StateServer" timeout="20" stateConnectionString="tcpip=server:port" />
   
Refer the following link for more information:
http://msdn.microsoft.com/en-us/library/h6bb9cz9(v=vs.100).aspx


2) Add the tag under tag in the web.config file of all the front end servers

The machine key can be generated from the following link:
http://aspnetresources.com/tools/machineKey

For Example:
<machineKey validationKey="41C11977666D4433D736559D3479711373A51E1F53161F81718B466B08AA23A48E45CF6F897C38F233C7A2A5A4C5754B73C53CF8A438417DFECE5EF2A63C1B82" decryptionKey="C13134ECD5DA5A8CBBE8FF0A0DCD973783B311C01ACBFD152F04DEBDA51613CB" validation="SHA1" decryption="AES" />


3) Start the ASP.NET State Service from "services.msc" and ensure that the client and server ports are the same.

If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection.

If the server is on the local machine, and if the above mentioned registry value does not exist or is set to 0, then the state server connection string must use either 'localhost' or '127.0.0.1' as the server name.

Taking Backup of Deployed WSP in SharePoint 2010

To take the backup of the WSP in SharePoint 2010,
Run the following commands from Powershell where SharePoint 2010 is configured.

Add-PSSnapin Microsoft.SharePoint.PowerShell
$farm = Get-SPFarm
$file = $farm.Solutions.Item(“mysolution.wsp”).SolutionFile
$file.SaveAs(“C:\WSPs\mysolution.wsp”)

This saves the wsp to the desired location. The WSP can then be deployed like any other solution.

Taking Backup of Deployed WSP in SharePoint 2007

To take a backup of installed WSP files in Central Administration, we need to run the SharePoint Farm Solution Extracator that can be downloaded from the following link

http://archive.msdn.microsoft.com/SPSolutionExtractor

Copy Dlls from the GAC

Open the CommandPrompt and Type:

cd c:\windows\assembly\GAC_MSIL

xcopy . C:\GacDump /s /y

This should give the dump of the entire GAC.

Wednesday, March 24, 2010

Interface between MATLAB and VB.NET

To interface MATLAB and VB.NET a .dll file has to be created.

Steps to create a dll file

1) Open MATLAB  R2009a  software
2) Type deploytool in the MATLAB Command Window and press Enter key
3) A new Deployment Tool Window will be opened
4) Click on the New Deployment Project Icon (Circled in the figure below)




5) Select the MATLAB Builder NE option
6) Then Select Generic COM Component, enter a name of the project and press OK




7) A new deployment project will be created
8) Add the MATLAB .m files to the project by clicking on the icon circled below





9) Note that the .m files must be a function. For example, file Test2.m contains the function as follws:


Test2.m

function y = Test2(p)
y = imread(p); % reads image file
j = rgb2gray(y); % converts a colored image to grayscale image
imwrite(j,'C:\matlabtempimage.jpg','jpg'); % stores the image to a location in hard disk



10) More than one .m files can be added
11) Also other files such as C, C++ etc. can also be added
12) After adding all the desired files Click on Build Project icon (Circled in the image below)




13) A new dialog window Deployment Tool Output will open
14) For the first time only it will ask you to select a compiler for compiling the project
15) Click on the link in the new window opened and select a compiler form the list provided by entering the number next to the compiler and press Y to confirm
16) I would suggest select Visual C++ 2008 Compiler
17) After selecting the compiler the MATLAB program will start compiling the project. It will display Compilation completed successfully if there are no errors else it will display the errors. It takes some time so be patient.
18) After the compilation Click on the package button, circled in the figure below




19) After packaging a folder with the project name will be created in the MATLAB folder
20) The dll file is present in the src and distrib folder
21) The dll file has to be registered in order to use it in VB.NET

Two ways for registering the dll file:

Method 1

• Open DOS Command prompt
• Give the location of the dll file present in the src folder. For example:

C:\>cd C:\Documents and Settings\My Documents\MATLAB\Test\src

Then enter the command regsvr32 space (dll filename) For example:

C:\Documents and Settings\My Documents\MATLAB\Test\src>regsvr32 Test_1_0.dll

The following message will be displayed





Method 2

Double Click on the _install.bat file in the distrib folder. The dll file will be registered automatically



After registering the dll file, Open Microsoft Visual Basic 2008
• Open the your project and select Project --> Add Reference
• Select COM --> Select your dll file --> Click on OK
• The dll file will then be added as reference

Note that each time changes are made to the .m file the above process of building, packaging, registering and adding as reference must be repeated.


Example on How to call the dll file


Form1.vb

 
Public Class Form1
Private cal As Test.TestClass

....

....

Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Dim d, b As Object
cal = New Test.TestClass
d = Me.OpenFileDialog1.FileName
Call cal.Test2(1, b, d)
End Sub

....

End Class

Tuesday, January 5, 2010

LATEX - A tool for documentation

I was introduced to LATEX during a workshop held in our college.

LATEX is the most useful tool in preparing technical or non-technical documents. LATEX is a scripting language.

Technical documents mostly contain equations and symbols such as summation, integration, etc. which cannot be created in Word. In such cases LATEX is useful.

If any changes are made in a document created in Word, the alignment and the number of pages also change. Hence the user has to not only concentrate on the content but also on the format. This is very time consuming.

As LATEX is based on scripts which have a predefined format, the user has to only set the format once and can concentrate on the contents of the documentation. Any changes made to the document in future will automatically follow the pre-set format. This saves the users time.

While LATEX is very useful, the only challenge lies in learning the scripts. But once learned it can be helpful  in creating documents with ease.

LATEX is mainly used on Linux Operating System, but it is also available for Windows and MAC.

Further details on LATEX is avalable at 

http://www.pinteric.com/miktex.html