nikhil joshi
Posts tagged windows
Modules in CLR
Sep 3rd
Basics
- Packaging deploying and discovering components code in CLR is different from COM, Java or Win 32.
- Programs written in CLR reside in module.
- Module is byte stream typically stored as a file in the local file system or on a web server.
Format of CLR module
- CLR module uses an extended version of PE/COFF executable file format used by Windows NT.
- Due to use of PE/COFF format CLR modules are valid win 32 module that can be loaded using LoadLibrary() system call.
Generating modules at run time
- use System.Reflection.Emit namespace
- CodeDom: it gives higher level of abstraction removing need to know or understand CIL.
Types of modules
RAW, LIBRARY and EXECUTABLE are three types of modules. Let us go through each one in more details
RAW
- By default this modules will use .netmodule file extension.
- This module cannot be deployed by there own nor the CLR can load them directly.
- This module need to be associated with full-fledged components i.e. assembly.
- Usage of raw module
- Multi-language assemblies
- Separately maintained source files
- Small download footprint
- Link the same source files into multiple assemblies
LIBRARY
- By default, this module will use .dll file extension.
- This module contains additional Meta data that allows deploying it as stand-alone code.
- This module cannot be launched as executable program from command shell or windows explorer.
EXECUTABLE
- By default file extensions are .exe (use console UI sub-system) or .winexe (use GUI sub-system)
- Must have initial entry point i.e. method that CLR will execute automatically when the program is launched.
- This method should be static
- This method does not need to declaration as public.
- This method must inside type definition.
- Name of type is immaterial.
- If there are more than one type contains main method, you need to resolve it manually.
Reference
- Essential .NET Volume 1 by Don Box
- MSDN
- etutorials.org
- Netmodule vs. Assembly
WinSock2 Client Server in VC++
Jul 6th
I was working with OpenSSL and VC++, I found that there are very few references available which tell us how to implement OpenSSL through VC++. But real thing missing is Working Client server in VC++ which will communicate through OpenSSL. So Writing one
Lets start with WinSock2 client server.
VC++ Code details
- VS2005
VC++ references required:
(From MSDN)Use the Winsock API by including the Winsock 2 header files. The Winsock2.h header file contains most of the Winsock functions, structures, and definitions. The Ws2tcpip.h header file contains definitions introduced in the WinSock 2 Protocol-Specific Annex document for TCP/IP that includes newer functions and structures used to retrieve IP addresses.
- Add #include <winsock2.h> and #include <ws2tcpip.h> in code
- Add build environment links to the Winsock Library file WS2_32.lib
Source code : click this link WinSock2-BasicClientServer
WinSock2 Server
We need to follow following steps to implement Server
- Initialize Winsock.
- Create and Bind the socket.
- Listen on the socket for a client.
- Accept a connection from a client.
- Receive and send data.
- Disconnect.
WinSock2 Client
- Initialize Winsock.
- Create a socket.
- Connect to the server.
- Send and receive data.
- Disconnect.
This is working fine but no fun. Lets make it working in threads.
Net will be client server communicating with each other in different threads; like read thread and write threads.
Windows 7 RC1 Review for hp nx7400 laptop
May 29th
I just installed windows 7 RC on my laptop. This is review
Device drivers status
| Hardware | Working status |
| Display | Working (Auto detected) |
| Dual Screens | Working (Auto detected) |
| Sound | Working (Auto detected) |
| LAN Broadcom 440x 10/100 | Working (Auto detected) |
| WLAN Broadcom 110 | Working (Auto detected) |
| Bluetooth | Not Working by default. |
GUI experience
| GUI | Very good |
| Speed of OS | Very good |
| Networking | Not very impressive |
| Backward GUI compatibility | Bad |
Overall rating 7.5/10
First week
1. Installed Software –Visual Studio 2008.
2. Not even single crash.
3. No lags.
4. Lot of Updates
as this is RC this is acceptable.
Get all database names form MSSQL 2005
Apr 9th
String conxString = “Data Source=” + server + “; Integrated Security=True;”;
using (System.Data.SqlClient.SqlConnection sqlConx = new System.Data.SqlClient.SqlConnection(conxString)) {
sqlConx.Open();
DataTable tblDatabases = sqlConx.GetSchema(“Databases”);
sqlConx.Close();
foreach (DataRow row in tblDatabases.Rows) {
Console.WriteLine(“Database: ” + row["database_name"]);
}
}
Check given IP address is valid for given machine
Mar 24th
Given code useDns.GetHostAddresses(). This function resolves machine host name to IP address. And if IP address is given it check for IP address and if valid returns given IP address.
-
string machineName = "localhost";
-
string checkIP = "127.0.0.1";
-
-
IPAddress[] ipsMachineName = null;
-
IPAddress[] ipsCheckIP = null;
-
//fetch IPs for machine
-
try {
-
ipsMachineName = Dns.GetHostAddresses(machineName);
-
}
-
catch (Exception expMachine) {
-
Console.WriteLine(string.Format("Error while retriving IP address of machine ‘{0}’ : {1} ", machineName, expMachine.Message));
-
return;
-
}
-
//Check IP addrss
-
try {
-
ipsCheckIP = Dns.GetHostAddresses(checkIP);
-
}
-
catch (Exception expIP) {
-
Console.WriteLine(string.Format("Invalid IP address: {0}", expIP.Message));
-
return;
-
}
-
//check ip address.
-
bool validIPAddress = false;
-
foreach (IPAddress machineIP in ipsMachineName) {
-
foreach (IPAddress cIP in ipsCheckIP) {
-
if (string.Compare(machineIP.ToString(), cIP.ToString(), true) == 0) {
-
validIPAddress = true;
-
break;
-
}
-
}
-
if (validIPAddress) {
-
break;
-
}
-
}
-
if (validIPAddress) {
-
Console.WriteLine("Valid IP address");
-
}
-
else {
-
Console.WriteLine("Invalid IP address");
-
}
How to start crawling of search on sharepoint site
Mar 23rd
Given command uses stsadmin tool provided by dear Microsoft. This command will start crawling of content forcefully. This is a heavy operation for SQL server.
This command will be required if
1. Your default crawling time is like every 12 hrs and you want to start crawling right now.
2. Some site are not performing search even if search is working for other site.
Steps:
Open a command window and paste following command
cd C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
stsadm.exe -o spsearch -action fullcrawlstart
Make search working for host header based sharepoint site
Nov 19th
This article assumes that search service is working. If you want help in starting search service feel free to contact me.
Search is very messed up problem with WSS [Windows Sharepoint Service 3.0]. Search is not working on your setup is because WSS is not able to find sharepoint site/Web applications.
Let have a quick overview of how search works
Windows SharePoint Services 3.0 uses the same SharePoint search technology used by Enterprise Search in Microsoft Office SharePoint Server 2007 rather than relying on Microsoft SQL Server full-text searching, as previous versions of Microsoft Windows SharePoint Services did.
Search in Windows SharePoint Services addresses a single site collection, and is automatically scoped to current context and limited to site and subsites, list or library, or folder. If you are looking at a subsite, you cannot search over the entire site collection, but you can search over all subsites of the current site.
Only SharePoint content in the site collection can be crawled. You cannot configure Search to crawl databases, mail servers, application servers, or Web sites and file shares outside of the site collection. In a deployment with more than one site collection, each site collection provides Search only for content on that site collection, and there is no aggregation of search results across site collections.
Content Crawling
Most of the capabilities for Search are configured automatically during installation.
One content source is automatically created for all user content Web applications. No administration details are exposed to site administrators. When a new site is created, the site’s URL is added to the start addresses for the content source.
One content source is automatically created for the Central Administration Web application. Full crawls occur as specified in the Administrator-controlled crawl schedule on the Central Administration configuration page.
Steps to make search work
Your site must be locally browseable on Search server. To avoid error “HTTP 401.1 – Unauthorized: Logon Failed” that comes while browsing site follow the steps given in MS KB article http://support.microsoft.com/kb/896861
Create Web Application and set search server.
- Create web application for host header site collection
- Add search server instance to content database. Go to Sharepoint central administration -> Application management -> content database -> Select web application -> click on content database then select search server
- Add URL of web application and IP address in IIS site
- Add URL and IP in C:\WINDOWS\system32\drivers\etc\hosts on search server. [ This step is very important as this enable local browsing of web application]
- Create host header base site in search enabled web application.
- Just add URL and IP in C:\WINDOWS\system32\drivers\etc\hosts on search server.
Troubleshooting steps:
Check content is crawled or not
- Go to the SQL server where search database is created.
- Browse table and find and open the table “MSSCrawlHostList”
- This table contain columns
- “HostName” which represent url of web application
- “SuccessCount” which represent Sucees ful crawls
- “ErrorCount” this means YOU ARE IN trouble
- Your site must have at least one “SuccessCount”
Check for Exact error for which search is failing
- Go to “administrative tool” -> “event viewer”
- Find out error under “Application”

Recent Comments