Expresso: Design and test regular expressions before you compile: Ultrapico
WinMerge: Compares files and directories: Winmerge
XVI32: A hex editor. With this I learned about the BOM: Christian Maas
While these tools are great, they can really add to your productivity when you integrate them into Visual Studio. When you right click a file in the solution and use "Open With…" You can add these tools to the list of applications.
Back in the old days, when dinosaurs roamed the earth, developers wanting to exchange data between applications used binary formatted data, hardcoded text field lengths, or delimited text files. Much parsing and error checking was involved. It was tedious.
With XML files a lot of that work can be done automatically… with one major drawback: You have to learn yet another 'language': XSD.
Here is how to create XML Schemas using classes in the .Net framework without knowing anything about XSD:
protected void Button1_Click(object sender, EventArgs e)
{
// The DataSet name becomes the root XML element
DataSet MyDataSet = new DataSet("Golfers");
// This can be confusing, the 'DataTable' will actually
// become Elements (Rows) in the XML file.
DataTable MyDataTable = new DataTable("Golfer");
MyDataSet.Tables.Add(MyDataTable);
// Make columns attributes so we can
// link directly to a GridView
MyDataTable.Columns.Add(new DataColumn("ID",
typeof(System.Int32),
null,
MappingType.Attribute));
// Write out the XSD
MyDataSet.WriteXmlSchema(@"C:\GolfersSchema.xsd");
// Put some data in the table
DataRow TempRow;
TempRow = MyDataTable.NewRow();
TempRow["ID"] = 1;
TempRow["Name"] = "Bobby Jones";
TempRow["Birthday"] = new DateTime(1902, 3, 17);
MyDataTable.Rows.Add(TempRow);
// Write out the data
MyDataSet.WriteXml(@"C:\Golfers.xml");
}
Here is how the data is saved, not bad eh?
Here is what the Schema looks like. Note, you can always go into the schema and tweak things.
Here is one way to validate the XML against the Schema:
protected void Button2_Click(object sender, EventArgs e)
{
// First, read in the XML schema
DataSet MyDataSet = new DataSet();
MyDataSet.ReadXmlSchema(@"C:\GolfersSchema.xsd");
// Now, read in the XML file (it is validated
// against the schema when it is read in).
MyDataSet.ReadXml(@"C:\Golfers.xml");
// See how it looks in a GridView
GridView1.DataSource = MyDataSet;
GridView1.DataBind();
}
You can test the validation by modifying the XML file and trying to read it:
set the homepage
The Microsoft .NET Framework SDK tools are designed to make it easier for you to create, deploy, and manage applications and components that target the common language runtime. You can run all the tools from the command line with the exception of the Assembly Cache Viewer (Shfusion.dll) and the Microsoft CLR Debugger (DbgCLR.exe). You must access the Assembly Cache Viewer (Shfusion.dll) from Windows Explorer. For information on each of the tools, see the .NET Framework Tools section in the .NET Framework SDK documentation. Unless otherwise noted, the tools are located in the SDK's \bin directory. Note: For the .Net Framework tools to function properly, the Path, Include, and Lib environment variables must be set correctly. Set the Path, Include and Lib environment variables by running SDKVars.bat, located in the \v2.0\Bin directory. SDKVars.bat must be executed in every command shell. • Configuration and Deployment Tools • Debugging Tools • Security Tools • General Tools Configuration and Deployment Tools • ASP.NET IIS Registration Tool (Aspnet_regiis.exe) Allows an administrator or installation program to update the scriptmaps for an ASP.NET application to point to the ASP.NET ISAPI version associated with the tool. You can also use the tool to perform other ASP.NET configuration operations. Note: Aspnet_regiis.exe can be found in "%windir%\Microsoft.NET\Framework\v2.0.xxxx" where xxxx is the build number of the .NET Framework you are using. • Assembly Cache Viewer (Shfusion.dll) Allows you to view and manipulate the contents of the global assembly cache by using Windows Explorer. Note: Shfusion.dll can be found in "%windir%\Microsoft.NET\Framework\v2.0.xxxx" where xxxx is the build number of the .NET Framework you are using. • Assembly Linker (Al.exe) Generates a file with an assembly manifest from one or more files that are either resource files or Microsoft intermediate language (MSIL) files. Note: Al.exe can be found in "%windir%\Microsoft.NET\Framework\v2.0.xxxx" where xxxx is the build number of the .NET Framework you are using. • Assembly Registration Tool (Regasm.exe) Reads the metadata within an assembly and adds the necessary entries to the registry, which allows COM clients to create .NET Framework classes transparently. Note: Regasm.exe can be found in "%windir%\Microsoft.NET\Framework\v2.0.xxxx" where xxxx is the build number of the .NET Framework you are using. • Assembly Binding Log Viewer (Fuslogvw.exe) Displays details for failed assembly binds. This information helps you diagnose why the .NET Framework cannot locate an assembly at runtime. • Global Assembly Cache Tool (Gacutil.exe) Allows you to view and manipulate the contents of the global assembly cache and download cache. While Shfusion.dll provides similar functionality, you can use Gacutil.exe from build scripts, makefile files, and batch files. • Installer Tool (Installutil.exe) Allows you to install and uninstall server resources by executing the installer components of a specified assembly. Note: Installutil.exe can be found in "%windir%\Microsoft.NET\Framework\v2.0.xxxx" where xxxx is the build number of the .NET Framework you are using. • Manifest Tool (Mt.exe) Allows you to generate and merge unmanaged winSxS component manifests, and managed assembly manifests. • Isolated Storage Tool (Storeadm.exe) Lists or removes all existing stores for the currently logged-on user. • Native Image Generator Tool (Ngen.exe) Creates a native image from a managed assembly and installs it into the native image cache on the local computer. Note: Ngen.exe can be found in "%windir%\Microsoft.NET\Framework\v2.0.xxxx" where xxxx is the build number of the .NET Framework you are using. • .NET Framework Configuration Tool (Mscorcfg.msc) Provides a graphical interface for managing .NET Framework security policy and applications that use remoting services. This tool also allows you to manage and configure assemblies in the global assembly cache. Note: Mscorcfg.msc can be found in "%windir%\Microsoft.NET\Framework\v2.0.xxxx" where xxxx is the build number of the .NET Framework you are using. • .NET Services Installation Tool (Regsvcs.exe) Adds managed classes to Windows 2000 Component Services by loading and registering the assembly and generating, registering, and installing the type library into an existing COM+ 1.0 application. Note: Regsvcs.exe can be found in "%windir%\Microsoft.NET\Framework\v2.0.xxxx" where xxxx is the build number of the .NET Framework you are using. • Soapsuds Tool (Soapsuds.exe) Helps you compile client applications that communicate with XML Web services by using a technique called remoting. • Type Library Exporter (Tlbexp.exe) Generates a type library from a common language runtime assembly. • Type Library Importer (Tlbimp.exe) Converts the type definitions found within a COM type library into equivalent definitions in managed metadata format. • Web Services Description Language Tool (Wsdl.exe) Generates code for XML Web services and XML Web services clients from Web Services Description Language (WSDL) contract files, XML Schema Definition (XSD) schema files, and .discomap discovery documents. • Web Services Discovery Tool (Disco.exe) Discovers the URLs of XML Web services located on a Web server, and saves documents related to each XML Web service on a local disk. • XML Schema Definition Tool (Xsd.exe) Generates XML schemas that follow the XML Schema Definition (XSD) language proposed by the World Wide Web Consortium (W3C). This tool generates common language runtime classes and DataSet classes from an XSD schema file. • XML Serialization Pre-generation Tool (Sgen.exe) Generates serialization assemblies for use with XmlSerializer. The utility allows developers to pre-generate assemblies for serialization and deploying the assemblies with the application. Debugger Tools • Microsoft CLR Debugger (DbgCLR.exe) Provides debugging services with a graphical interface to help application developers find and fix bugs in programs that target the runtime. For more information, see The CLR Debugger topic in the .NET Framework SDK documentation. Note: The Microsoft CLR Debugger (DbgCLR.exe) is located in the SDK\v2.0\GuiDebug folder. • Managed Code Debugger (Mdbg.exe) Provides command-line debugging services to help application developers find and fix bugs in programs written using the .NET Framework. Use this tool to find and fix bugs in programs that target the runtime. • Runtime Debugger (Cordbg.exe) Provides command-line debugging services using the common language runtime Debug API. Use this tool to find and fix bugs in programs that target the runtime. Security Tools • Certificate Creation Tool (Makecert.exe) Generates X.509 certificates for testing purposes only. • Certificate Manager Tool (Certmgr.exe) Manages certificates, certificate trust lists (CTLs), and certificate revocation lists (CRLs). • Code Access Security Policy Tool (Caspol.exe) Allows you to examine and modify machine, user, and enterprise-level code access security policies. Note: Caspol.exe can be found in "%windir%\Microsoft.NET\Framework\v2.0.xxxx" where xxxx is the build number of the .NET Framework you are using. • PEVerify Tool (PEverify.exe) Performs MSIL type safety verification checks and metadata validation checks on a specified assembly. • Secutil Tool (Secutil.exe) Extracts strong name public key information or Authenticode publisher certificates from an assembly, in a format that can be incorporated into code. • Software Publisher Certificate Test Tool (Cert2spc.exe) Creates, for test purposes only, a Software Publisher's Certificate (SPC) from one or more X.509 certificates. • Strong Name Tool (Sn.exe) Helps create assemblies with strong names. Sn.exe provides options for key management, signature generation, and signature verification. General Tools • License Compiler (Lc.exe) Reads text files that contain licensing information and produces a .licenses file that can be embedded in a common language runtime executable. • Management Strongly Typed Class Generator (Mgmtclassgen.exe) Allows you to quickly generate an early bound class in C#, Visual Basic, or JScript for a specified Windows Management Instrumentation (WMI) class. • MSIL Assembler (Ilasm.exe) Generates a PE file from Microsoft intermediate language (MSIL). You can run the resulting executable, which contains MSIL code and the required metadata, to determine whether the MSIL code performs as expected. Note: Ilasm.exe can be found in "%windir%\Microsoft.NET\Framework\v2.0.xxxx" where xxxx is the build number of the .NET Framework you are using. • MSIL Disassembler (Ildasm.exe) Takes a PE file that contains MSIL code and creates a text file suitable as input to the MSIL Assembler (Ilasm.exe). • Resource File Generator Tool (Resgen.exe) Converts text files and .resx (XML-based resource format) files to .NET common language runtime binary .resources files that can be embedded in a runtime binary executable or compiled into satellite assemblies. • Visual J# Binary Converter Tool (JbImp.exe) It converts certain Java-language bytecode (.class) files to Microsoft® intermediate language (MSIL). This tool enables developers to convert most JDK 1.1.4–level libraries and applications available only as bytecode files to MSIL assemblies and run them on the .NET Framework with the Visual J# Redistributable Package. Use this tool only if the Java-language sources for the applications or libraries are not available. If Java-language sources are available, it is recommended that you use the Visual J# compiler (vjc.exe) instead. Note: To use this tool, the Visual J# Redistributable Package 2.0 must be installed. Installing the Visual J# Redistributable Package 2.0. • Windows Forms ActiveX Control Importer (Aximp.exe) Converts type definitions in a COM type library for an ActiveX control into a Windows Forms control. • Windows Resource Localization Editor (Winres.exe) Allows you to quickly and easily localize Windows Forms forms.
I haven't been impressed by any new technology in a long time…until I downloaded and tried out the new Microsoft Chart Controls for the .Net Framework. It contains charts for both Forms and Asp.Net applications. The Charts home page is here: http://code.msdn.microsoft.com/mschart
To try the control, I started with an SQLDataSource connected to the NorthWind database. I used a custom SQL String to sum up the sales for each week (7 days) given a beginning OrderDate. For the OrderDate parameter, I used a Calendar control.
ConnectionString="<%$ ConnectionStrings:NorthWind %>"
SelectCommand="
SELECT OrderDate, Sum(Quantity * Unitprice) as OrdersTotal
FROM Orders, [Order Details]
WHERE Orders.OrderID = [Order Details].OrderID AND
OrderDate BETWEEN @OrderDate AND dateadd(day, 7, @OrderDate)
GROUP BY OrderDate
ORDER BY OrderDate">
ControlID="Calendar1"
DefaultValue="7/30/1996"
Name="OrderDate"
PropertyName="SelectedDate" />
I dropped a GridView onto the form and fired it up to make sure the data connectivity was working. Clicking dates on the Calendar, causes the GridView to update immediately.
Next, I dropped the Chart control from the Data tab of the ToolBox. I set the DataSourceID to be the same as the GridView's DataSourceID.
The number of settings in the Chart control can be a bit overwhelming at first but if you dig around and drill down, you will eventually find what you need: With power and flexibility comes complexity.
The final Asp markup code was surprisingly short:
BackColor="LightSkyBlue"
BackGradientStyle="VerticalCenter"
BackSecondaryColor="128, 128, 255"
BorderlineColor="Black"
BorderlineDashStyle="Solid"
BorderlineWidth="3"
DataSourceID="SqlDataSource1"
Width="400px" Height="300px"
Style="top: 337px; left: 18px; position: absolute">
Text="Weekly Sales by Day"
Font="Times New Roman, 12pt, style=Bold">
Here is the resultant image:
Of course, I should remove the .00 from the Y Axis, increase the font size of the Y Axis Title, change the format of the X Axis labels to show the day of week, etc. There are tons (and I mean tons) of features with this control….you could spend hours tweaking this thing. But it sure looks good.
Sometimes we need to convert text into the images on the fly. This tool converts the text into image and displays it onto the web page without saving it into a file on the disk. It also takes care of text wrapping. TextToImageConvertor can either be used in a web page or in a module. I have used this code in a web page. To use TextToImageConvertor in a module, you will need to make some changes in the step 8. The code for TextToImageConvertor is self explanatory. However, I am going to describe this step-by-step. Step 0 - Include Namespaces using System.Drawing;using System.Drawing.Imaging; Step 1 - Declare Properties Declare some variables that will control the behavior and color of the image. string Text = Request.QueryString["Text"]; Color FontColor = Color.Blue; Color BackColor = Color.White; String FontName = "Times New Roman"; int FontSize = 10; int Height = 150; int Width = 150; Step 2 - Create a Bitmap Object to Hold The Image Bitmap bitmap = new Bitmap(Width, Height); Step 3 - Create a Graphics object using this Bitmap object Graphics graphics = Graphics.FromImage(bitmap); Step 4 - Create Color, Font, and PointF objects. Color color = Color.Gray; ;Font font = new Font(FontName, FontSize); //define where the text will be displayed in the specified area of the imagePointF point = new PointF(5.0F, 5.0F); Step 5 - Create Brushes and Pen SolidBrush BrushForeColor = new SolidBrush(FontColor);SolidBrush BrushBackColor = new SolidBrush(BackColor);Pen BorderPen = new Pen(color); Step 6 - Draw Rectangle using Graphics object Rectangle displayRectangle = new Rectangle(new Point(0, 0), new Size(Width - 1, Height - 1));graphics.FillRectangle(BrushBackColor, displayRectangle);graphics.DrawRectangle(BorderPen, displayRectangle); Step 7 - Draw Text string on the specified rectangle using Graphics object //Define string format StringFormat format1 = new StringFormat(StringFormatFlags.NoClip);StringFormat format2 = new StringFormat(format1);//Draw text string using the text formatgraphics.DrawString(Text, font, Brushes.Red, (RectangleF)displayRectangle, format2); Step 8 - Send the bitmap to page output stream in JPEG format Response.ContentType = "image/jpeg";bitmap.Save(Response.OutputStream, ImageFormat.Jpeg); Using TextToImageConvertor TextToImageConvertor is developed as a web page which can be accessed directly by passing the text in he query string. To demonstrate the use of this tool, create a webpage with a textbox, a button and an image control. On the click event of the button, set the image URL to the convertor page and pass the text of text box into the query string. In the example code below, I have named my image control as img1 and text box as txtNote. img1.ImageUrl = "default2.aspx?Text=" + txtNote.Text;
Microsoft has a new web site to start the excitement on his new dev technologies: IE8, WPF, Silver light and Windows Mobile. It is called {You shape} it and focus on Design, Development and IT Management in a nice clay motion Silver light UI.
The MSDN Architecture Center has information and examples about the latest techniques and trends, demonstrating how technology aligns to your current business needs. Learn what others are doing and how challenges are being addressed, but also share your ideas and participate in the forums.
This guidance helps architects and developers build SharePoint intranet applications. The guidance contains a reference implementation (RI) that demonstrates solutions to common architectural, development, and lifecycle management challenges Download: SharePoint Guidance – November 2008
If you need to stop a datareader in the middle, instead of at the end, you have to call cancel on the command object. Calling the Close() method will result in a timeout exception. using (SqlCommand cmd = new SqlCommand(sql, conn)){ XmlReader reader = cmd.ExecuteXmlReader(); reader.Read(); while (!reader.EOF) {if (this.Cancel){cmd.Cancel();reader.Close():break;}holder = reader.ReadOuterXml(); } }
Copying a website (to another exact copy) Here is the command to copy a website(run from a cmd prompt – c:\inetpub\adminscripts): > cscript.exe adsutil.vbs copy > cscript.exe adsutil.vbs copy w3svc/1 w3svc/556 The numbers mentioned there are nothing but the website identifiers. After copying, you might see the other (new) website stopped – just because the old one still runs on the same port and IP address combination. Taking an exact copy of website sometime comes handy where you just do not want to restart IIS for restoring a backup, but can restore the copy you took after playing with the original one. Copying only the ISAPI Filters (to another website) This is pretty simple – you can use this example to just copy *any* node in the Metabase to another website. > cscript adsutil.vbs copy w3svc/1/Filters w3svc/2/Filters Hope this helps!
Reading the contents of a web page is so easy in .net Try the below code and see the O/P.
WebRequest req = WebRequest.Create("http://www.hcl.in"); WebResponse res = req.GetResponse(); StreamReader sr = new StreamReader(res.GetResponseStream()); string html = sr.ReadToEnd();
The web project model changed in number of ways from Visual Studio 2003 to Visual Studio 2005, But one major part which is missing is the ability to version the assembly using AssemblyInfo.cs file. This is because the model of VS 2005 dynamically creates multiple assemblies for each class file. Resulting in which we cannot have single named assembly to set version number. We cannot change the default behavior of compilation but we can change the way we can deploy our project files and assemblies, by using Web Deployment Project. Microsoft Web Deployment Project adds numerous features which nicely integrates with Visual Studio 2005, out of which the most useful I found is: More control over number of assemblies generated by a pre-complied web application as well as control over the naming of the output assemblies. Which means you can generate either single assembly for you entire project, and select the name and version you want for e.g Foo.dll, etc or generate the assemblies per directory/ pages or control. The ability to customize and modify the web.config file during deployment, that means you need not to change you web.config file every time before making release or deploying the project, instead you can specify the web.config keys on Web Deployment project, that you use for deployment, like this you can customize any other web.config settings also. These are the few things which I named here, if you want more information on how to install, and use this you can visit the Scott's Blog from the below link: http://weblogs.asp.net/scottgu/archive/2005/11/06/429723.aspx Or you can Download the VS 2005 Web Deployment Project from WebDeploymentSetup.msi Other Useful Links which may help you to further explore this subject http://msdn.microsoft.com/en-us/library/aa479568.aspx Web Deployment Projects Forum