Free Downloadable E-Book Offers from Microsoft Press MCP Flash Feb 2009
Reading the MCP Flash of February 2009 I came to the next three free e-book offers which are a great way to stay up to date on the latest Microsoft technologies.
Remembering the Query String
You already used it but how dit you passed that value using a Query String?
"A query string is the part of a URL that contains data to be passed to web applications (e.g. http://server/path/program?query_string=value)."
// A) Add a querystring to the entire url
String newUrl = Context.Request.Url.ToString() + "?ItemID={0}";
// B) Check or there is a Query String
if(Page.Request.QueryString.AllKeys.Length == 0)
{ // Do something }
// C) Write all keys and values from the Query String
using System.Collections;
using System.Collections.Specialized;
...
NameValueCollection collection = Request.QueryString;
String[] keyArray = collection.AllKeys;
Response.Write("Keys:");
foreach (string key in keyArray) {
Response.Write(" " + key +": ");
String[] valuesArray = collection.GetValues(key);
foreach (string myvalue in valuesArray) {
Response.Write("\""+myvalue + "\" ");
}
}
[/code]
ZoomIt V2.2 for zooming in Technical Presentations
"ZoomIt is screen zoom and annotation tool for technical presentations that include application demonstrations. ZoomIt runs unobtrusively in the tray and activates with customizable hotkeys to zoom in on an area of the screen, move around while zoomed, and draw on the zoomed image. I wrote ZoomIt to fit my specific needs and use it in all my presentations.
ZoomIt works on all versions of Windows and you can use pen input for ZoomIt drawing on tablet PCs."
Download: http://technet.microsoft.com/en-us/sysinternals/bb897434.aspx
Microsoft releases the Open Source CMS Oxite
Microsoft releases the first version of the opensource-cms Oxite. This content management system is based on ASP.NET and the Model View Controller (MVC) Framework. This CMS is primary released for blogs. Since the use of ASP.NET this software requirers windows servers (hosting). "Oxite is an open source, standards compliant, and highly extensible
content management platform that can run anything from blogs to big web
sites."
Download Oxite: http://www.codeplex.com/oxite
Learn More: http://visitmix.com/lab/oxite
First Public Description of the planned language features of C Sharp 4
A first public description of the planned language features of C# 4.0 (Visual Studio 2010) can be found in the next article on
MSDN.
Problem - Dynamic Load Webservice
After reading this mailthread on MSDN it seems to be possible to dynamically load a webservice (load on demand). However I got the following error on this line of code:
Object response = methodInfo.Invoke(obj, args);
[/code]
Also this tool on CodePlex causes the same error on the same line. Click on the image below for a screenshot of the error.
Since I get this error in a environment with a domain logon account I tried the following Credentials:
// method 1
webRequest.PreAuthenticate = true;
webRequest.Credentials = new NetworkCredential("username, "password", "domain");
// method 2
System.Net.CredentialCache.DefaultCredentials;
[/code]
All code is executed correctly. If it was really an authentication error I wasn't inpossible to read the webservice stream (in my opinion). So it seems I'm well authenticated.
Is there someone who get this working or have an alternative?
Thanks!!
Snippet Creator
In my archive I found this cool snippet tool. I wrote it a long time ago (for Visual Studio 2005) for easily create C# code snippets for Visual Studio 2005. Maybe it would be useful for you as basic application for further development.
Click on the image below for a screenshot.
// Snippet files are saved in:
// C:\Documents and Settings\<User>\My Documents\Visual Studio 2005\Code Snippets\Visual C#\My Code Snippets
// or
// C:\Program Files\Microsoft Visual Studio 8\VC#\Snippets\1033\Visual C#
namespace SnippetCreator
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void WriteSnippetFile(String fileName)
{
FileStream file = File.Create(fileName);
StreamWriter writer = new StreamWriter(file);
writer.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
writer.WriteLine("<CodeSnippets xmlns=\"http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet\">");
writer.WriteLine("<CodeSnippet Format=\"1.0.0\"><Header><Title>");
writer.Write(txtTitle.Text);
writer.WriteLine("</Title><Shortcut>");
writer.Write(txtShortCut.Text);
writer.WriteLine("</Shortcut></Header><Snippet><Code Language=\"CSharp\"><![CDATA[");
writer.Write(txtSnippetCode.Text);
writer.Write("]]></Code></Snippet></CodeSnippet></CodeSnippets>");
writer.Close();
file.Close();
}
private void button1_Click(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(txtTitle.Text) ||
String.IsNullOrEmpty(txtShortCut.Text) ||
String.IsNullOrEmpty(txtSnippetCode.Text))
{
MessageBox.Show("Some fields are empty! Please fill out them and try again...");
return;
}
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Title = "Save a Snippet File";
saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\Visual Studio 2005\Code Snippets\Visual C#\My Code Snippets";
saveFileDialog.Filter = "Snippet File|*.snippet";
saveFileDialog.ShowDialog();
try
{
if (saveFileDialog.FileName != "")
{
WriteSnippetFile(saveFileDialog.FileName);
}
MessageBox.Show("Snippet: " + txtTitle.Text + " succesfully added!");
txtTitle.Clear();
txtShortCut.Clear();
txtSnippetCode.Clear();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
}
}
[/code]
RSS Feeds to DataSet using DotNet
The following static function returns a generic list of the type "Feed" containing the RSS Feeds based on a url. As an option you can also specify a proxy.
namespace RssFeed
{
public class Feed
{
private string title;
public string Title
{
get { return title; }
set { title = value; }
}
private DateTime pubDate;
public DateTime PubDate
{
get { return pubDate; }
set { pubDate = value; }
}
private string link;
public string Link
{
get { return link; }
set { link = value; }
}
private string description;
public string Description
{
get { return description; }
set { description = value; }
}
public static List<Feed> GetRssFeedList(String rssUrl)
{
WebProxy proxy = new WebProxy("proxy.myurl.com", true);
DataSet ds = new DataSet();
Uri url = new Uri(rssUrl);
HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
objRequest.Proxy = proxy;
WebResponse response = (objRequest.GetResponse());
StreamReader stream = new StreamReader(response.GetResponseStream());
ds.ReadXml(stream);
DataTable table = ds.Tables["item"];
List<Feed> feeds = new List<Feed>(table.Rows.Count);
foreach (DataRow row in table.Rows)
{
Feed feed = new Feed();
try
{
feed.Title = row["title"].ToString();
feed.PubDate = Convert.ToDateTime(row["pubDate"]);
feed.Link = row["link"].ToString();
feed.Description = row["description"].ToString();
feeds.Add(feed);
}
catch (Exception)
{
// error handling
}
}
return feeds;
}
}
}
[/code]
Microsoft Pre-release Software Visual Studio 2010 and .NET Framework 4.0 Community Technology Preview
Microsoft Visual Studio 2010 and the .NET Framework 4.0 are the next generation development tools and platform for Windows Vista, the 2007 Office System, and the Web. You can download them from the
Microsoft Site.
Embrace the new .NET Logo
On the MOSSY Blog you can read about the new .NET-logo which stand for: consistency, robustness and great user experiences.