Ido Samuelson

Notes, thoughts and exceptions

<November 2008>
SuMoTuWeThFrSa
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456


Navigation

Blogs I read

Articles

My WorkSpaces

Subscriptions

News

Only 10 kind of people in the world. Those who understand binary and those who don't.

Post Categories

Article Categories



Bye bye DotNetJunkies

Without putting much words to it. My blog is moving from dotnetjunkies and from now on my host will be DevAuthority.

My new blog address is : http://devauthority.com/blogs/samuelson/default.aspx

Ido

posted Thursday, July 14, 2005 4:46 AM by snick

Composite UI Application Block - Community Technical Preview

The Composite UI Application Block is designed to help you build these complex, enterprise ready Windows Forms—based solutions. It provides a proven architecture and implementation that helps you to build applications using the common patterns found in line-of-business front end applications.

Benefits

Building an application using the Composite UI Application Block provides the following benefits:

  • Increased solution quality and consistency for architecture teams by providing a structured, prescriptive environment that fosters reusability and predictability to build user interfaces.
  • Increased productivity and faster ramp-up time for large development teams, by hiding complexity and allowing them to focus on the business related components instead of on the underlying infrastructure and complex aspects of user interface development, such as threading and asynchronous processing.
  • Consolidation of operational efforts for operations teams by standardizing services that result in consistent configuration management and instrumentation implementations across a suite of applications.

This Community Technical Preview of the Composite UI Application Block can be downloaded from the Community Site. Important updates to this component until its final release will be made available on this site.

 

posted Wednesday, July 06, 2005 11:28 AM by snick

Enterprise Library June 2005 now available!

Enterprise Library June 2005 now available!

The June 2005 release is a minor update to the original January release. It incorporates the patches and extensions previously released to the community, and also includes miscellaneous minor bug fixes. Although this release is still designed for .NET Framework 1.1, it is now possible to use this with .NET Framework 2.0 beta 2 - see the included Readme file for details.

 

 

posted Saturday, July 02, 2005 6:14 PM by snick

Generics is cool...

I finally got some time to play with generics...

The most usable generic class I use is as follow :

[Serializable]

public class EventArgs<T> : EventArgs

{

   private T t;

   public EventArgs(T t)

   {

       this.t = t;

   }

   public T Data

   {

      get { return t; }

   }

}

Just cool!!!

posted Tuesday, June 28, 2005 11:55 AM by snick

Register HotKey fix

I wrote a HotKey component a few month ago and some reported me a bug that suspend, shutdown or restart did not work while the Hotkey was in use.

This bug was fixed and I updated the code on the original post: http://dotnetjunkies.com/WebLog/principal/archive/2005/04/21/69872.aspx

I was trying to find a way to register a hotkey without the use of the form's handle and the code that was on that post was one of those tries...

posted Tuesday, June 21, 2005 11:05 AM by snick

a small example of what a programmer should NOT do...

What you would do when you see the following code:

public object GetObject()

{

   if (myObject != null)

      return myObject;

   else

      return null;

}

posted Tuesday, June 21, 2005 10:38 AM by snick

No more comments....

For the last month I received over a 1000 spam emails from my blog. I guess it is a good time to remove the comments from my blog for a few weeks...

posted Tuesday, June 21, 2005 10:15 AM by snick

Service Locator Applicaion Block v1.0

Service Locator 1.0 is an application block which integrates with Enterprise Library 1.0. It's a general-purpose, provider-driven object factory, which can be used to create instances of component servers, following the Service Locator design pattern.

http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=41A621E5-3628-4C71-8985-710C4475F347

posted Tuesday, June 21, 2005 10:12 AM by snick

Second code drop of CAB ready to download

Second code drop of CAB ready to download

 

Check out this new code drop of the Composite UI Application Block that now includes most of the core services (like EventBroker, Module Loader, etc), the long awaited UI support services along with QuickStarts and draft introductory documentation. Please let us know what you think about it sending an email to: pagcabfb@microsoft.com Thanks! patterns & practices Smart Client Team

posted Friday, June 17, 2005 11:12 AM by snick

Data Mapping Application Block

"The Data Mapper is a layer of software that separates the in-memory objects from the database. Its responsibility is to transfer data between the two ends to isolate them from each other. With Data Mapper the in-memory objects needn’t know even that there’s a database present; they need no SQL interface code, and certainly no knowledge of the database schema." (Fowler, Martin, Patterns of Enterprise Application Architecture, p. 165) Data Mappers equate to what is known as Data Access Logic Components (DALCs). This application block is intended to make it easier for producers of business DALCs to create common functionality that relates to managing "entities" with CRUD functions. The DataMapper also promotes the use of stored procedures as a best practice to abstract data access from the underlying data schema and increase performance. Finally, the DataMapper allows capabilities like the use of transactions, command timeouts, and caching properties to be added, removed, and modified through configuration when needed. For example, to add transactions or caching to a DALC, no code will need to be modified -- only configuration settings.”

Find out more here

posted Tuesday, June 14, 2005 7:58 AM by snick

Looking for a new host...

For the last couple of weeks I recieved a huge amount of spam from this blog.

I am now looking for a new (better and spam proof) place to host my blog.

If you are familier with a decent host please contact me.

Ido

posted Wednesday, June 08, 2005 11:07 AM by snick

MSN Messenger personal messages

Since MSN Messenger 7.0 released many people started to use the personal message to put a state about their feelings, life and “hints” they want to give to a specific person on their contact list.

I think the “personal” message is a very good way for a non formal communication. If you are a sensitive person with emotional intelegent abilities I am sure you know what I mean...

Here are some of the personal messages I have on my list...

  • “There ain't no such thing as free lunch.” - R. A. Henlein
  • I love deadlines, I like the whooshing sound they make as they fly by.
  • Professionals built the Titanic, amateurs built the Ark of Noah.
  • Ignorance is bliss.
  • Still haven't seen Ep3...
  • Mortgage is all you <don't> need
  • Don't kill the messenger!

as for my own:

“It is wonderful to be in on the creation of something, see it used, and then walk away and smile at it.” – Lady Bird Johnson

 

Life could be so beautiful if you just stop for a look :-)

posted Sunday, May 22, 2005 10:38 AM by snick

Enterprise Library DataTierGenerator Tool Sample

This sample illustrates an application built using the DataTierGenerator for Enterprise Library available at http://workspaces.gotdotnet.com/datatiergenerator. This tool generates a data tier that uses the Entlib data access block to update the database“

Find it here

posted Sunday, May 22, 2005 8:06 AM by snick

Enterprise Library Exit Poll

“Have you just completed a project that uses Enterprise Library? We want to hear from you! The Exit Poll is a survey specifically aimed at people who have finished a project using Enterprise Library, so you can share your experiences on how it went from beginning to end. We will use this information to help improve future releases. If you are using Enterprise Library but have not yet completed the project, please hold off on completing the survey until the project is released.

If you work with EntLib, tried EntLib or had anything to do with EntLIB. This is very important to fill out this poll :-)

Fill it here, via EntLib gotdotnet workspace

posted Sunday, May 22, 2005 6:28 AM by snick

Enterprise Library 1.0 Hands On Labs

Some mystic way returned EntLib to my life this week. Am still trying to figure out the reason.

I got 2 questions from 2 different people regarding signing EntLib with a strong name (it is possible!). I helped Ohad Israeli with his EntLib web cast by answering all kind of questions... (I think the community still think that the ExceptionHandler is the same as the ExceptionPublisher which is 100% NOT!!!). Then I got to talk about EntLib somemore for a good friend who just promoted to a team leader and would love to work with EntLib. Finally to summerize it all up. MS released the long waited HOL for EntLib.

Hope you enjoyed my blah blah :-)

Oh, and the link for the HOL is here

posted Saturday, May 21, 2005 5:21 AM by snick

RegisterHotKey Implementation

Dan Amiga who is a great co-worker and a very tallent person showed me a very cool shortcuts application (C++) he wrote. I was so amazed about how easy it is to access any applications with few key strokes that I went home and wrote my own implementation for the same applciation, in C# of course.

The #1 thing I did was to implement this Component which fires a HotKeyPressed event when a desired windows HotKey was pressed.

Here is the implementation :

UPDATE: There was a mistake with the intptr Handle. Notice that now you need to supply the Form.Handle to this component. Suspend, Shutdown and Restart will work properly now...

public class HotKey : Component , IMessageFilter

   {

      public event EventHandler HotKeyPressed;

      private const int id = 100;

      #region Native win32 API

      private const int WM_HOTKEY = 0x0312;

      [DllImport("user32.dll", SetLastError = true)]

      private static extern bool RegisterHotKey(IntPtr hWnd, int id, KeyModifiers fsModifiers, Keys vk);

      [DllImport("user32.dll", SetLastError = true)]

      private static extern bool UnregisterHotKey(IntPtr hWnd, int id);

      [Flags()]

      public enum KeyModifiers

      {

         None = 0,

         Alt = 1,

         Control = 2,

         Shift = 4,

         Windows = 8

      }

      #endregion

      public event EventHandler KeyChanged;

      public event EventHandler KeyModifierChanged;

      private IntPtr handle;

      public IntPtr Handle

      {

         get { return handle; }

         set { handle = value; }

      }

      private Keys key;

      private KeyModifiers keyModifier;

      private bool isKeyRegisterd;

      public HotKey()

      {

         Application.AddMessageFilter(this);

      }

      ~HotKey()

      {

         Application.RemoveMessageFilter(this);

         UnregisterHotKey(handle, id);

      }

      private void RegisterHotKey()

      {

         if (key == Keys.None)

            return;

         if (isKeyRegisterd)

            isKeyRegisterd = !(UnregisterHotKey(handle, id));

         isKeyRegisterd = RegisterHotKey(handle, id, keyModifier, key);

         if (!isKeyRegisterd)

            throw new ApplicationException("Hotkey allready in use");

      }

      [Bindable(true), Category("HotKey")]

      public Keys Key

      {

         get { return key; }

         set

         {

            if (key != value)

            {

               key = value;

               OnKeyChanged(new EventArgs());

            }

         }

      }

      [Bindable(true), Category("HotKey")]

      public KeyModifiers KeyModifier

      {

         get { return keyModifier; }

         set

         {

            if (keyModifier != value)

            {

               keyModifier = value;

               OnKeyModifierChanged(new EventArgs());

            }

         }

      }

      public bool PreFilterMessage(ref Message m)

      {

         switch (m.Msg)

         {

            case WM_HOTKEY:

               OnHotKeyPressed(new EventArgs());

               return true;

         }

         return false;

      }

      private void OnHotKeyPressed(EventArgs e)

      {

         if (HotKeyPressed != null)

         HotKeyPressed(this, e);

      }

      private void OnKeyChanged(EventArgs e)

      {

         RegisterHotKey();

         if (KeyChanged != null)

            KeyChanged(this, e);

      }

      private void OnKeyModifierChanged(EventArgs e)

      {

         RegisterHotKey();

         if (KeyModifierChanged != null)

            KeyModifierChanged(this, e);

      }

}

posted Thursday, April 21, 2005 9:56 PM by snick

DataSet tips

Although am not a big fan of Datasets, Datasets are the core Entities in several projects am working on.

I encounter over and over again, specially in IT projects how Dataset are being used without being aware what is happening behind the scene. I decided to write some tips on how to use them...

for each DataTable in a DataSet there is a boolean property named Enforceconstraints. This property means that it will Enforce the constraints of your data to make sure the data is valid via it's schema. Which means that if I use the DataAdapter to fill a curtein Table, the enforce constrains will make sure the data is valid. This leads me to tip #1

TIP #1 Enforceconstraints= false when you fill your DataTable. This will improve your loading performance. (you should Enforceconstraints= True after Fill completed)

Another 2 important methods that I keep reminind the server side developers is to make use of the very important 2 methods of a DataTable. BeginLoadData() and EndLoadData(). If you aren't using those two methods now, you should go back and fix your code.

TIP #2 Make sure you ALWAYS use BeginLoadData() before you load data to a DataTable. The reason is that BeginLoadData() simply turn off notification, index maintenance, and constrains while loading data.

TIP #3 Make sure you ALWAYS use EndLoadData() after data was loaded to a DataTable. To simply turn on notification, index maintenance, and constrains.

The last 2 tips are more familier to developers, but mainly because it's being used by the CurrencyManager in DataBinding... In  DataRow object there are 2 methods that should be used when you want to make a change to more then one column in a row. BeginEdit() and EndEdit().

TIP #4 While Updating more then 1 column in a DataRow, call BeginEdit() before you change the values. Events are temporarily suspended allowing the user to make multiple changes to more than one row without triggering validation rulesIn

TIP #5 After updating the values of a DataRow, call EndEdit() to accept the updates.  Events will be enabled again. EndEdit() method is called implicitly when you invoke the DataTable object's AcceptChanges() method.

Futhermore, I strongly suggest to read the MSDN comments regarding these functions, it will sure improve your coding skills.

posted Wednesday, April 13, 2005 7:25 PM by snick

FXcop chat on Microsoft Chat Room

Just now the FXcop chat was ended on Microsoft Chat Room.

I asked several questions that was troubling my mind. Here is a cool answer that made me think of a cool application to write...


MikeFan [MS] (Expert):
Q: Will FxCop work with reflection which means that I will have to build the assembly before I get the information about what rules I broken?

A: FxCop is a binary analyzer. So, yes, you must build your assemblies before we can analyze them. FxCop does not use reflection for this work, we have our own, entirely passive metadata reader that cracks binaries and extracts IL for analysis. This metadata reader allows us to avoid loading your assembly into the runtime, which provides several advantages (such as the ability to recompile your dlls with FxCop up and analyzing them).


MikeFan [MS] (Expert):
Q: Wow! MikeFan, will you release a code sample on how to access the assembly metaData without the need to use reflection?

A: We will not be distributing metadata reader samples, no. The reason for this is that our metadata reader is not itself a redistributable library. There is an initiative internally to provide external customers an alternate metadata reader. The group is code-named Phoenix, if you're interested in non-reflection-based assembly browsing, you might try to get more info on them (search the web). Also, Lutz Roeder (author of Reflector and also an MS employee) has developed his own metadata reader that is available for download by visiting his web site. Search on his name or 'reflector' to find a link.

posted