Posts

Showing posts from March, 2011

Making your application LARGEADDRESSAWARE if it is 32 bit

http://stackoverflow.com/questions/2597790/can-i-set-largeaddressaware-from-within-visual-studio In the post build event: call "$(DevEnvDir)..\tools\vsvars32.bat" editbin / LARGEADDRESSAWARE "$(TargetPath)"

Enable Visual Studio to use more than 2GB of memory

Very useful when you have more memory: http://mkwec.de/2010/01/08/make-visual-studio-use-more-than-2-gig-of-memory/ "Using Visual Studio can be quite frustrating: even having a big quad processor 8 gig SSD raid machine it will still complain not being able to complete an operation because there is not enough “storage” available. Ever seen this “Not enough storage is available to complete this operation.”-Message in large solutions with many projects? Actually this “storage” means memory and you can use the following steps to provide more memory to visual studio: Windows XP users only:  add the /3GB switch to your boot.ini (make sure you backup your old boot.ini before) Windows Vista users only: from the Visual Studio command prompt run: BCEDIT /Set IncreaseUserVa 3072 Apply large address awareness to visual studio by running: editbin /LARGEADDRESSAWARE devenv.exe in your <path-to-VS>/Common7/IDE (make sure you backup your old devenv.exe) Reboot Now Visual Stu

Editing the hosts file on Mac OS/X

It was getting to be a pain to do name resolution while connecting to VPN from a mac. So, here is a link which shows how to add the names and ip address to the hosts file. Interesting that the folder and file name is same as that what windows uses http://decoding.wordpress.com/2009/04/06/how-to-edit-the-hosts-file-in-mac-os-x-leopard/

.LDF file growing too large?

Here is how to shrink it: http://support.microsoft.com/?id=272318 In easy terms, do the shrink, if it does not work, backup the database and do the shrink again! (You might have to change the backup type to Simple from Full).

A WriteThreadSafeCollection implementation

/// <summary>     /// In this class modifying the list is thread safe. To enumerate through the list, always lock the SyncRoot property, otherwise it will not be thread safe. This is the recommended way of making a collection thread safe.     /// </summary>     /// <typeparam name="T">The type of the entity for which the collection is created.</typeparam>     [Serializable]     [DataContract]     public class WriteThreadSafeCollection<T> : Collection<T>     {         private object _syncLock = new object();                public WriteThreadSafeCollection() : base()         {         }           public WriteSynchronizedCollection(IList<T> sourceList) : base()         {             this.AddRange(sourceList);         }            protected override void InsertItem(int index, T item)         {             lock (_syncLock)             {                 base.InsertItem(index, item);             }         }      

VS 2008 breakpoints not hit when you have sp1 and windows 2008 r2 x64 OS

Found the solution to this horrible problem here: http://social.msdn.microsoft.com/Forums/en/vsdebug/thread/f3fcb4fb-8a08-4fa0-8d58-9ed6f3eb1193 The latest Silverlight 3 installer for vs 2008 did not fix the issue fully. I had to install the specific patch from here: http://code.msdn.microsoft.com/KB957912/Release/ProjectReleases.aspx?ReleaseId=1796 Note that if your OS is x64, you need to install the below first: http://www.microsoft.com/downloads/details.aspx?FamilyID=440ec902-3260-4cdc-b11a-6a9070a2aaab

Calling a method using delegates asynchronously

using System.Threading; using System.Runtime.Remoting.Messaging; private void ActualAsyncMethodCalled() { } private void AsyncMethodCallBack(IAsyncResult result)         {             lock (result)             {                 AsyncResult asyncResult = (AsyncResult) result;                 if (asyncResult.AsyncDelegate != null)                 {                     Action sourceAction = (Action)asyncResult.AsyncDelegate;                     sourceAction.EndInvoke(result);                 }             }         } public void Main() {         Action asyncAction = ActualAsyncMethodCalled;         asyncAction.BeginInvoke(new AsyncCallback(AsyncMethodCallBack), null); } Using Action<T> if the method to be called takes one parameter, always call end invoke when you call begin invoke. Only in windows forms Control.BeginInvoke, this rule is explicitly not required as per MSDN.

Redirecting Console and Debug Output to a textbox.

            _consoleStreamWriter = new TextBoxStreamWriter(txtConsoleOutput, tabConsole);             _debugStreamWriter = new TextBoxStreamWriter(txtDebugOutput, tabDebugPage);             TextWriterTraceListener writer = new TextWriterTraceListener(_debugStreamWriter);             Debug.Listeners.Add(writer);             Debug.WriteLine("Now redirecting debug output.");             // Redirect the out Console stream             Console.SetOut(_consoleStreamWriter);             Console.WriteLine("Now redirecting console output."); To prevent application crash when writing to the Textbox (which will happen with the default code found elsewhere), do the below: public class TextBoxStreamWriter : TextWriter     {         private StringBuilder messageBuilder = new StringBuilder();         private TextBox _output = null;         private Control _parentControl = null;         private System.Timers.Timer _displayTimer = new System.Timers.Timer();