We're looking to hire solid ASP.NET developers - If you think you gots the skills to hang with us submit your resumes.

newtelligence AG ist ein führender Provider für Softwareentwickler-Services mit Standort in Korschenbroich, Rheinkreis Neuss. Wir unterstützen unsere Kunden in Europa mit Beratung, Architekturentwürfen und –reviews, Coaching, Projektbegleitung und Workshops im Bereich der Microsoft .NET-Technologien.  Wir suchen talentierte Junior Developer mit professioneller Erfahrung für unser Team von Beratern, Trainern und Entwicklern. Wenn Sie auf mindestens ein Jahr Erfahrung in kommerzieller Softwareentwicklung verweisen können und tiefgehende Kenntnisse im Bereich der Microsoft .NET-Plattform haben, möchten wir Ihnen gerne unsere offenen Positionen im Bereich Consulting und Kleinprojekt-Entwicklung vorstellen. Kenntnisse sind insbesondere in den Bereichen ASP.NET (C# oder VB) erwünscht. Erfahrungen in den Bereichen Web-Services, Life-Cycle-Tools sowie in COM, VB und Datenbanken sind von Vorteil. Was wir noch erwarten: Sehr gute Kommunikationsfähigkeiten in Deutsch und Englisch (schriftlich wie mündlich) Sowohl Teamfähigkeit als auch selbständiges Arbeiten unter minimaler Anleitung Verantwortungsbewusstsein Flexibilität Reisebereitschaft Belastbarkeit  

Lennybacon says #1: Exceptions and ValidatorControls

I often get asked things through my messenger and today I decided to start sharing a few lines of the conversations...    Frank: Is there a way to connect a Validator to an Exception so that the validation summary can be used to display the exception message? Lennybacon says: 1. build a Custom Validator Frank: Ok Lennybacon says: 2. Use Page_Error or catch to set a "flag" to the Validator Lennybacon says: 3. override the method EvaluateIsValid and return the state of the flag Lennybacon says: This way the validator (if called on the postback) indicates its validation as true and after the flag is set false. Lennybacon says: Here is some pseudo-code Lennybacon says:        try        {          CriticalOperation();        }        catch(MyException e)        {          MyValidator.SetInvalid();          MyValidator.ErrorMessage = "bla bla: " + e.Message;          Page.Validate();        } Lennybacon says:        Validator : CustomValidator        {           bool flag = true;           void setInvalid(){flag=false;}           bool EvulateIsValid()           {                return flag;           }        }   http://www.staticdust.net/downloads/Web.ExceptionVisualizer.zip

Encrypting Files using DPAPI

In one of my current projects (yes, there are more at the moment and yes that is the reason why it's a bit quiet around here) i neede to write an encrypted file to the hard disc using DPAPI (Data Protection API). After I unsuccessfully searched the web and the msdn (the sample reads all bytes to the buffer at once - not so nice), I wrote the following sample app: using System; using System.IO; using System.Security.Cryptography;   public class DataProtectionSample {     public static void Main()     {         using(MemoryStream ms = new MemoryStream())         {             StreamWriter swriter = new StreamWriter(ms);             swriter.WriteLine("Text to encrypt to file.");             swriter.Flush();               Console.WriteLine("Protecting data ...");             DataProtection.Protect("D:\\_temp\\DPAPI.dat", ms, false);         }         Console.WriteLine("Unprotecting data ...");         using(MemoryStream ms2 =             (MemoryStream)DataProtection.Unprotect("D:\\_temp\\DPAPI.dat", false))        {             StreamReader sreader = new StreamReader(ms2);             Console.WriteLine("");             Console.WriteLine("Decrypted string: " + sreader.ReadToEnd());         }         Console.ReadLine();     } }   public class DataProtection {     private static byte[] _additionalEntropy = { 9, 8, 7, 6, 5 };     private static int _bufferLength = 1024;       public static void Protect(string filename, Stream stream,         bool machineLevel)     {         if (File.Exists(filename))         {             File.Delete(filename);         }         using (FileStream fs = new FileStream(filename, FileMode.CreateNew))         {             byte[] buffer = new byte[_bufferLength];             long byteCount;             stream.Position = 0;             while ((byteCount =                stream.Read(buffer, 0, buffer.Length)) > 0)             {                 buffer = ProtectedData.Protect(buffer, _additionalEntropy,                     ((machineLevel) ? DataProtectionScope.LocalMachine :                     DataProtectionScope.CurrentUser));                 fs.Write(buffer, 0, buffer.Length);                 fs.Flush();             }         }     }       public static Stream Unprotect(string filename, bool machineLevel)     {         MemoryStream ms = new MemoryStream();                 using (FileStream fs = new FileStream(filename, FileMode.Open))         {             byte[] buffer = new byte[_bufferLength + 146];             long byteCount;               while ((byteCount =                fs.Read(buffer, 0, buffer.Length)) > 0)             {                 buffer = ProtectedData.Unprotect(buffer, _additionalEntropy,                     ((machineLevel) ? DataProtectionScope.LocalMachine :                     DataProtectionScope.CurrentUser));                 ms.Write(buffer, 0, buffer.Length);                 ms.Flush();             }         }         ms.Position = 0;         return ms;     } }      

Executing CREATE statements from within Visual Studio 2005

If you try to run a CREATE statement in a query (right click on a database in the Server Explorer) you receive this message. So i wrote a small utility which will do the job for me. using System; using System.IO; using System.Data.SqlClient; using System.Collections.Generic; using System.Text; using System.Windows.Forms;   namespace MdfExec {     class Program     {         static void Main(string[] args)         {             string _cnStr;               if (args.Length == 2)             {                 _cnStr =                     "data source=.\\SQLEXPRESS;Integrated Security=SSPI;" +                     "AttachDBFilename=" + args[1] + ";User Instance=true;";             }             else             {                 OpenFileDialog fd = new OpenFileDialog();                   fd.AddExtension = true;                 fd.DefaultExt = ".mdf";                 fd.ShowDialog();                   _cnStr =                     "data source=.\\SQLEXPRESS;Integrated Security=SSPI;" +                     "AttachDBFilename=" + fd.FileName + ";User Instance=true;";             }               using (SqlConnection _cn = new SqlConnection(_cnStr))             {             using(SqlCommand _cmd = _cn.CreateCommand())                    {                     using (StreamReader fs = File.OpenText(args[0]))                     {                         _cmd.CommandText = fs.ReadToEnd();                         _cmd.Connection.Open();                         _cmd.ExecuteNonQuery();                     }                    }             }         }     } }   You can now right click on a *.sql file choose "open with ..." and select MdfExec.exe to execute the SQL statement. Since there is no second parameter (but needed to define to which database to connect) a OpenFileDialog will prompt:   Happy coding

Customizing the Prop Snippet

I'm quite busy with a project I'm on with Clemens (the last before he'll join the Indigo team at Microsoft) - just to explain why it got bit quiet around me :-) Here is a modified version of the prop snippet that I want to share ( and remember :-P ). <?xml version="1.0" encoding="utf-8" ?> <CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">       <CodeSnippet Format="1.0.0">             <Header>                   <Title>prop</Title>                   <Shortcut>prop</Shortcut>                   <Description>Code snippet for property and                   backing field</Description>                   <Author>Microsoft Corporation</Author>                   <SnippetTypes>                         <SnippetType>Expansion</SnippetType>                   </SnippetTypes>             </Header>             <Snippet>                   <Declarations>                         <Literal>                              <ID>type</ID>                               <ToolTip>Property type</ToolTip>                              <Default>int</Default>                         </Literal>                         <Literal>                              <ID>property</ID>                              <ToolTip>Property name</ToolTip>                              <Default>MyProperty</Default>                         </Literal>                         <Literal>                              <ID>field</ID>                              <ToolTip>The variable backing this                              property</ToolTip>                              <Default>myVar</Default>                         </Literal>                   </Declarations>                   <Code Language="csharp"><![CDATA[#region $property$             // This field holds the $property$       private $type$ $field$;         /// <summary>Gets/sets the $property$.</summary>       /// <value>A <see cref="$type$">$type$</see>       /// containing the $property$.</value>       /// <remarks>This property gets/sets the $property$.</remarks>       [System.ComponentModel.Description("Gets/sets the $property$.")]       public $type$ $property$       {             get { return $field$;}             set { $field$ = value;}       }       #endregion       $end$]]>                   </Code>             </Snippet>       </CodeSnippet> </CodeSnippets>

Complex Databinding

I just finished writing some ASP.NET code where I also typed the following lines:  <ItemTemplate> <asp:Image ID="IsOnline" runat="server" ImageUrl='<%# GetImageUrl((MembershipUser)Container.DataItem) %>' /> </ItemTemplate> ... protected string GetImageUrl(MembershipUser user) { if (user.IsLockedOut) { return "~/images/BadUser.gif"; } else if (!user.IsApproved) { return "~/images/GreyUser.gif"; } else if (user.IsOnline) { return "~/images/OnlineUser.gif"; } else { return "~/images/OfflineUser.gif"; } } Before I shutdown my machine I fetchted Mail and Feeds when i ran accross this posting by ScottGu pointing to Fritz Onions Blog. ;-)

Code like i want to see it with ASP.NET 2.0

A short statement additional to my post against the spagetti code because I think Scott got me wrong: The Object Data Source is one of the coolest things out there cause it's never been so easy to use n-tier applications and bind custom business objects to databound controls. And this is exactly what I tell the folks out there in my articles and talks.

ASP.NET Features vs Real Applications

The most important thing to point out whenever I talk about ASP.NET 2.0 data-driven applications is:     "With the SqlDataSource and GridView or   DetailView controls you can         quickly build up tiny applications that just      need to be set up asap.       This has to do nothing with REAL   best practice applications!" Therefore I was pretty happy to read "The Code Spaghetti generation is back" in Pascal Leloup's Blog (Help .NET). Here is my statement:

Cool Tool: Cassini here power toy

[...]The .NET Framework 2.0 comes with a built-in webserver, based on the old Cassini web server. So I wanted to be able to easily set up any directory to have its contents served up on an as-needed basis. The result is an addition to the Windows Explorer right-click menu...[Robert McLaws] Chris Fraizer wrote it thgether in a small app. Here is my version with a few modifications: using System; using System.IO; using System.Collections.Generic; using System.Diagnostics; using System.Windows.Forms; using System.Text; using System.Runtime.InteropServices;   namespace WebServerHere {     class Program     {         static void Main(string[] args)         {             if (args.Length >= 1)             {                 string _path;                   string _command =                     Path.Combine(                     RuntimeEnvironment.GetRuntimeDirectory(),                     "WebDev.WebServer.EXE");                   StringBuilder _commandArgs = new StringBuilder();                   Random _r = new Random();                   string _port = _r.Next(1024, 9000).ToString();                   if (args.Length == 2)                 {                     _port = args[1];                 }                     //grab the original path                 _path = args[0];                   _commandArgs.Append(" /path:\"");                 _commandArgs.Append(_path);                 _commandArgs.Append("\"");                 _commandArgs.Append(" /port:");                 _commandArgs.Append(_port);                 _commandArgs.Append(" /vpath: \"/");                 _commandArgs.Append(_path.Substring(                     _path.LastIndexOf('\\') + 1));                 _commandArgs.Append("\"");                   ProcessStartInfo _info =                     new ProcessStartInfo();                   _info.Arguments = _commandArgs.ToString();                 _info.CreateNoWindow = true;                 _info.FileName = _command;                 _info.UseShellExecute = false;                 _info.WorkingDirectory =                     _command.Substring(0, _command.LastIndexOf('\\'));                     Process.Start(_info);                   using (Control _c = new Control())                 {                     Help.ShowHelp(_c, "http://localhost:" + _port + "/");                 }             }             else             {                 MessageBox.Show("Usage:\n\tWebServerHere.exe <path> [port]",                     "WebServerHere", MessageBoxButtons.OK,                     MessageBoxIcon.Information);             }         }     } } And the Non-Admin installation reg-file: Windows Registry Editor Version 5.00 [HKEY_Current_User\SOFTWARE\Classes\Folder\shell\VS2005 WebServer]@="ASP.NET 2.0 Web Server Here" [HKEY_Current_User\SOFTWARE\Classes\Folder\shell\VS2005 WebServer\command]@="\"%SystemRoot%\\System32\\WebServerHere.exe\" %1"

.NET SummerCamp 2005 Leipzig

Torsten Weber invited me to do one day of sessions at the .NET Summercamp: I introduced .NET 2.0 and C# 2.0 and talked about Visual Studio 2005 Team System. It was the first time in Leipzig and i really liked it. Hopefully i'll be there next year too.