Posts
56
Comments
307
Trackbacks
0
Tuesday, September 06, 2011
St. Louis Day of .NET 2011 - Sessions Materials

I have to say that it has been awhile (just over a year actually) since I've updated my blog.  I feel embarassed.  On the other hand, I have been quite busy - so it's not like I don't do it because I am lazy (well I am somewhat lazy), but it's because time is somewhat a scarce resource.  But... I will try to see if I can muster up some moments to be active with my blog.

With that said, last month (August 5th and 6th) St. Louis held the 4th annual conference of the St. Louis Day of .NET.  It was a rousing success - over 800 people came, and great fun was had by all.  Kudos to the organizers for holding the event; I contributed by presenting 3 sessions, which I will detail below.  I promised to put the session materials up ASAP, but other things got in the way and some procrastination ended up with me doing it only now (a month after the event).  My apologies to those that are looking for the materials...

I have been interested in mobile development - have ventured into Windows Phone 7 development, since it is just a short hop away from my regular work dealing with WPF and XAML in general.  On the other hand, I always felt that I needed to get out of my comfort zone and try to look at other platforms as well.  So I actually started tinkering with iOS sometime last year - spent my hard-earned income to buy myself a MacBook Pro.  My background in C / C++ development tremendously helped with learning Objective-C, but it was still a steep learning curve.

For this year's St. Louis Day of .NET, I decided to share my newfound knowledge and did 2 sessions that are NOT .NET related - I did a session titled 'Looking at Objective-C' - and try to introduce fellow .NET developers to this language, which can look strange indeed.  The material posted contain the PowerPoint presentation, so it is useful to read / page through for those that do not have a Mac PC.  It also has the simple project that I did within the session, but the worth of the session (IMHO) is in exposing what Objective-C looked like to other developers (which primarily are .NET developers).

I also did another session on 'Introduction to iOS Development' - providing a code walkthrough on creating a simple consumer-based application that can take pictures, record video and play some music.  Unlike the Objective-C session, the material posted are mostly code; there is no PowerPoint in it.  Although the code files can be read with Notepad (or your favorite editor / text viewer), you need Xcode and a Mac PC to compile the code.  Since the code will try to take pictures / video, you also need to deploy the resulting code onto a device since the iOS simulator doesn't support cameras.

Not to forget my roots - I did a C# focused session in 'Test Your Practical C# Knowledge'; I made the session as a multiple-choice Jeopardy-style session complete with first and second round questions.  Unfortunately I could not muster 3 brave enough participants that is needed to go up front and involve themselves.  So we made it as a quiz / learning session, it was a free-for-all the attendees in the room.  Some of the code described is not quite practical, but I thought it was great to see how developers walk through the code in their mind. 

The first link contains only the project and code files (to proof / verify the question), and I also used images to display the question - because of the size, the images are broken up into first round questions and second round questions.  I get to learn a couple of new tidbits on C# along the way, and the session seem to involve the attendees so they were actively searching for the answer as well.

In the end, the goal of me doing these sessions are to help myself with ensuring I am familiar with the materials I should be familiar with, and also helping others know / learn more about technologies in general.  On a personal note, I really liked the Objective-C session because learning that language was very eye-opening for me; I know it's mostly syntax differences, I am just surprised they took that particular syntax.  Hopefully these materials can be of use to others...

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
Posted On Tuesday, September 06, 2011 4:10 AM | Feedback (1)
Saturday, August 21, 2010
Materials for the St. Louis Day of .NET 2010 presentations - part two

Finished my session on Asynchronous Adventures in Silverlight an hour ago, and I'm putting up the presentation files.

The session is Asynchronous Adventures in Silverlight. Since there are enough sessions about developing XAML, WPF and Silverlight, I've decided to do a session that emphasized the asynchronous nature of most operations that is the default mode of operations in Silverlight.  The session talks about the asynchronous pattern used and how widespread it is, discuss about some pitfalls, advantages and disadvantages. The files can be downloaded here.

I hope this can be of use to others.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
Posted On Saturday, August 21, 2010 5:37 AM | Feedback (0)
Thursday, August 19, 2010
Materials for the St. Louis Day of .NET 2010 presentations - part one

I'm going to be giving a presentation for the St. Louis Day of .NET 2010 - TODAY!

Worked out my materials for the first 2 sessions, for those that are interested, they can download the materials:

The first session is: JumpStart: Workflow 4.  The session describes the core features and technology involved in developing and managing your Activity enriched application workflows using Windows Workflow Foundation 4.0.  The files can be downloaded here.

The second session is Introduction to 3D in WPF.  This is an introductory session to show some of the 3D graphics capabilities in WPF. Participants will be introduced to the concepts of triangular polygon, GeometryModel3D, Viewports and the camera system. Some animation will be introduced along with some samples for how to draw texts on 3D surfaces.  The files can be downloaded here.

I still have one more session materials to upload, thus the 'part one' in the title .  Hopefully people find this informative.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
Posted On Thursday, August 19, 2010 11:51 PM | Feedback (0)
Tuesday, May 04, 2010
protected abstract override Foo(); – er... what?

A couple of weeks back, a co-worker was pondering a situation he was facing.  He was looking at the following class hierarchy:

abstract class OriginalBase
{
   protected virtual void Test()
   {
   }
}

abstract class SecondaryBase : OriginalBase
{
}

class FirstConcrete : SecondaryBase
{
}

class SecondConcrete : SecondaryBase
{
}

Basically, the first 2 classes are abstract classes, but the OriginalBase class has Test implemented as a virtual method.  What he needed was to force concrete class implementations to provide a proper body for the Test method, but he can’t do mark the method as abstract since it is already implemented in the OriginalBase class.

One way to solve this is to hide the original implementation and then force further derived classes to properly implemented another method that will replace it.  The code will look like the following:

abstract class OriginalBase
{
   protected virtual void Test()
   {
   }
}

abstract class SecondaryBase : OriginalBase
{
   protected sealed override void Test()
   {
      Test2();
   }

   protected abstract void Test2();
}

class FirstConcrete : SecondaryBase
{
   // Have to override Test2 here
}

class SecondConcrete : SecondaryBase
{
   // Have to override Test2 here
}

With the above code, SecondaryBase class will seal the Test method so it can no longer be overridden.  Then it also made an abstract method Test2 available, which will force the concrete classes to override and provide the proper implementation.  Calling Test will properly call the proper Test2 implementation in each respective concrete classes.

I was wondering if there’s a way to tell the compiler to treat the Test method in SecondaryBase as abstract, and apparently you can, by combining the abstract and override keywords.  The code looks like the following:

abstract class OriginalBase
{
   protected virtual void Test()
   {
   }
}

abstract class SecondaryBase : OriginalBase
{
   protected abstract override void Test();
}

class FirstConcrete : SecondaryBase
{
   // Have to override Test here
}

class SecondConcrete : SecondaryBase
{
   // Have to override Test here
}

The method signature makes it look a bit funky, because most people will treat the override keyword to mean you then need to provide the implementation as well, but the effect is exactly as we desired.  The concepts are still valid: you’re overriding the Test method from its original implementation in the OriginalBase class, but you don’t want to implement it, rather you want to classes that derive from SecondaryBase to provide the proper implementation, so you also make it as an abstract method.

I don’t think I’ve ever seen this before in the wild, so it was pretty neat to find that the compiler does support this case.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
Posted On Tuesday, May 04, 2010 6:25 AM | Feedback (1)
Tuesday, April 20, 2010
A quick hello to the Western Kentucky .NET User Group

A few days back, I got a chance to speak at the Western Kentucky .NET User Group meeting in Murray, Kentucky.  The opportunity came up because the original speaker, Jeff Blankenburg, had another obligation and was thus unable to come to this meeting.  I volunteered to deliver his presentation, which is an overview of MIX10 conference.

It was a great experience for me; got to drive around and do a little bit of sight-seeing – can’t say I’ve ever been to Kentucky before, so first trip ever there.  I got to meet the user group’s current lead, Tom Turner and got to chat and discuss about all kinds of stuff with the other members.  Cheers to Matt Gawarecki and Brandon Sharp!

The presentation itself mostly covers new features in Visual Studio 2010, which was recently released on April 12 – got to demonstrate Historical Debugging in IntelliTrace, Parallel Stacks, View Call Hierarchy and show some Extensions.  We also covered some of the new functionalities in Silverlight 4 (using webcams, drag & drop support among others) and I got to show off Scott Guthrie’s Windows Phone 7 Twitter app.  Altogether, it was quite a bit to cover in 70 minutes or so, but I think everyone enjoyed it.

Jeff provided me with the presentation slides (which I modify a bit) and demo applications; so I’m putting it up here for those that may be interested in downloading them.  Please keep in mind that all the demos were made with VS2010 RC, so there may be slight tweaks to get it to work on the RTM version.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
Posted On Tuesday, April 20, 2010 7:58 AM | Feedback (0)
Tuesday, January 12, 2010
Make KeyedCollection<TKey, TItem> to work properly with WPF data binding

In my previous post, I went through creating the KeyedCollectionEx class which allows easier consumption of the KeyedCollection class (no need to derive anymore, just provide a delegate).  One of the problem I encountered was that when using it as an ItemsSource in WPF, any changes to the collection will not be shown in the UI.  This is because the class doesn’t implement INotifyCollectionChanged interface.  So, let’s add that.

The implementation is fairly straightforward; the class itself has all of the methods that will actually change the collection (SetItem, InsertItem, ClearItems and RemoveItem) to be virtual so we just need to override it.  With the implementation, the code looks like the following (only listing the INotifyCollectionChanged implementation, see previous post for the constructor & delegate implementation):

public class KeyedCollectionEx<TKey, TItem> : KeyedCollection<TKey, TItem>, INotifyCollectionChanged
{
   // Overrides a lot of methods that can cause collection change
   protected override void SetItem(int index, TItem item)
   {
      base.SetItem(index, item);
      OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, item, index)); 
   }

   protected override void InsertItem(int index, TItem item)
   {
      base.InsertItem(index, item);
      OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, index)); 
   }

   protected override void ClearItems()
   {
      base.ClearItems();
      OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
   }

   protected override void RemoveItem(int index)
   {
      TItem item = this[index];
      base.RemoveItem(index);
      OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item));
   }

   protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   {
      if (CollectionChanged != null)
         CollectionChanged(this, e);
   }

   #region INotifyCollectionChanged Members

   public event NotifyCollectionChangedEventHandler CollectionChanged;

   #endregion
}

With the above code, now using this collection as an ItemsSource will cause WPF UIElements to show newly added / removed entities properly.  However, as detailed in my other post way back, if the collection is used a lot and does get bound as ItemSource to a lot of UIElements, adding / removing multiple items can hamper performance.

To alleviate that issue I’m adding a public method called AddRange (mimicking the AddRange method of List<T>).  I need a boolean variable (which I named _deferNotifyCollectionChanged) to indicate if the class should raise the event or not – if I don’t do that each call to Add will result in a CollectionChanged event being raised.  The code will then look like as follows:

private bool _deferNotifyCollectionChanged = false;
public void AddRange(IEnumerable<TItem> items)
{
   _deferNotifyCollectionChanged = true;
   foreach (var item in items)
      Add(item);
   _deferNotifyCollectionChanged = false;
   OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, new List<TItem>(items)));
}

protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
{
   if (_deferNotifyCollectionChanged)
      return;

   if (CollectionChanged != null)
      CollectionChanged(this, e);
}

There’s a problem with this though; if you call this method a NotSupportedException exception will be thrown; the message says ‘Range actions are not supported’.  Essentially the UIElements doesn’t support change notification where multiple items are changed.  As such we have to provide a workaround for this; either using the approach detailed in my other post, or by changing the AddRange method to the following:

public void AddRange(IEnumerable<TItem> items)
{
   _deferNotifyCollectionChanged = true;
   foreach (var item in items)
      Add(item);
   _deferNotifyCollectionChanged = false;

   OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
}

The code above is simpler than the other post (well, I’m learning new tips and tricks over the years and months).  Instead of specifying what has been added, the NotifyCollectionChangedAction used is Reset, which signals the CollectionChanged event subscribers that the collection has changed tremendously so it should re-read the whole collection.  Please use with care; if you have a list which have 10000 items and you’re only adding a small amount to that list, a Reset will be much more expensive than notifying individual addition.

Below is pasted the full source of the class.  Since the behavior has changed, I’m also renaming the class to ObservableKeyedCollection, which sounds better than adding an Ex to an existing class name.  I hope this can be of use to others.

public class ObservableKeyedCollection<TKey, TItem> : KeyedCollection<TKey, TItem>, INotifyCollectionChanged
{
   private Func<TItem, TKey> _getKeyForItemDelegate;

   // Constructor now requires a delegate to get the key from the item
   public ObservableKeyedCollection(Func<TItem, TKey> getKeyForItemDelegate) : base()
   {
      if (getKeyForItemDelegate == null)
         throw new ArgumentNullException("Delegate passed can't be null!");

      _getKeyForItemDelegate = getKeyForItemDelegate;
   }

   protected override TKey GetKeyForItem(TItem item)
   {
      return _getKeyForItemDelegate(item);
   }

   // Overrides a lot of methods that can cause collection change
   protected override void SetItem(int index, TItem item)
   {
      base.SetItem(index, item);
      OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, item, index)); 
   }

   protected override void InsertItem(int index, TItem item)
   {
      base.InsertItem(index, item);
      OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, index)); 
   }

   protected override void ClearItems()
   {
      base.ClearItems();
      OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
   }

   protected override void RemoveItem(int index)
   {
      TItem item = this[index];
      base.RemoveItem(index);
      OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item));
   }

   private bool _deferNotifyCollectionChanged = false;
   public void AddRange(IEnumerable<TItem> items)
   {
      _deferNotifyCollectionChanged = true;
      foreach (var item in items)
         Add(item);
      _deferNotifyCollectionChanged = false;

      OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
   }

   protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   {
      if (_deferNotifyCollectionChanged)
         return;

      if (CollectionChanged != null)
         CollectionChanged(this, e);
   }

   #region INotifyCollectionChanged Members

   public event NotifyCollectionChangedEventHandler CollectionChanged;

   #endregion
}
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
Posted On Tuesday, January 12, 2010 3:42 AM | Feedback (1)
Thursday, January 07, 2010
Using KeyedCollection<TKey, TItem>

A little over 2 years ago, I saw my peer’s code that uses the KeyedCollection<TKey, TItem> class.  I never seen it before, and it is actually a pretty nice class.  It is essentially a dictionary class, but with the stipulation that the key for each item added to the dictionary can be retrieved from the item itself. 

With a Dictionary, every time we wanted to add a new item into it, we have to call its Add method, which accepts 2 parameters, the key for the item and the item itself.  In most cases, the key already is in the item, so we’re just reduplicating it.  This KeyedCollection class provides a shortcut since we can just provide it a method so it can get the key for each item added automatically.

The following code show how Dictionary and KeyedCollection can be used:

// Class to contain data stuff
public class MyData
{
   public int Id { get; set; }
   public string Data { get; set; }
 }

// KeyedCollection is an abstract class, so have to derive
public class MyDataKeyedCollection : KeyedCollection<int, MyData>
{
   protected override int GetKeyForItem(MyData item)
   {
      return item.Id;
   }
}

private void Test()
{
   MyData temp, md = new MyData() { Id = 1, Data = "Test" };
   
   // Using a Dictionary
   Dictionary<int, MyData> dict = new Dictionary<int, MyData>();
   dict.Add(md.Id, md);  // Add to dictionary
   temp = dict[1];       // Retrieve

   // Using KeyedCollection
   KeyedCollection<int, MyData> keyd = new MyDataKeyedCollection();
   keyd.Add(md);         // Add to KeyedCollection
   temp = keyd[1];       // Retrieve
}

As you can see, usage is very, very similar to a Dictionary, with the only difference that the Add method only accepts 1 parameter.  Retrieval is exactly the same.  However, since KeyedCollection is an abstract class, you cannot use it directly; you have to derive from it and use your derived class – that’s why I created the MyDataKeyedCollection class.  This MyDataKeyedCollection class has to override the GetKeyForItem method (which is declared as an abstract method in the base class) so you can retrieve the key for the given item.  For me this is somewhat of a deal breaker – I have to always derive from it – there’s no way to use it easily, like a typical collection class.

So my next step is to try to make it easier to consume… thus I created my KeyedCollectionEx class.

public class KeyedCollectionEx<TKey, TItem> : KeyedCollection<TKey, TItem>
{
   private Func<TItem, TKey> _getKeyForItemDelegate;
   public KeyedCollectionEx(Func<TItem, TKey> getKeyForItemDelegate) : base()
   {
      if (getKeyForItemDelegate == null)
         throw new ArgumentNullException("Delegate passed can't be null!");

      _getKeyForItemDelegate = getKeyForItemDelegate;
   }

   protected override TKey GetKeyForItem(TItem item)
   {
      return _getKeyForItemDelegate(item);
   }
}

The constructor now requires a delegate that will get the TKey for the given TItem – I’m using the Func delegate which is in .NET 3.0, so if you’re using .NET 2.0, you need to create your own delegate signature.  With this, my test method becomes as follows:

private void Test2()
{
   MyData temp, md = new MyData() { Id = 1, Data = "Test" };

   // Using KeyedCollectionEx with anonymous delegate
   KeyedCollection<int, MyData> keyd = new KeyedCollectionEx<int, MyData>(delegate(MyData myData) { return myData.Id; });
   keyd.Add(md);         // Add to KeyedCollection
   temp = keyd[1];       // Retrieve

   // Using KeyedCollectionEx with lambda expression
   KeyedCollection<int, MyData> keyd2 = new KeyedCollectionEx<int, MyData>(myData => myData.Id);
   keyd2.Add(md);         // Add to KeyedCollection
   temp = keyd2[1];       // Retrieve
}

I demonstrated how to use it with anonymous methods (so I don’t have to create a method for it), and also how to use it with a lambda expression.  Much simpler, IMHO – no need to create a derived class.  However, I would like this to work with WPF’s data binding – so I’d like further enhance my KeyedCollectionEx class so it can notify WPF when items are being added or removed from it – that’ll be my next post.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
Posted On Thursday, January 07, 2010 10:42 AM | Feedback (9)
Friday, November 13, 2009
Connect to VMWare virtual machines using Remote Desktop

Had a short training on VMWare on Tuesday, the software development department finally got the official permission (read: get a license) to use VMWare Workstation.  I’m no stranger to Virtual Machines (VMs) – started playing with Virtual PC 2005 a fwe years back and I understood the general concepts of hardware virtualization.  The biggest problem I have with VMs in general is the slowness; I’d rather develop directly on my PC, which is faster.  Can’t say I’ve delved deep into it, but I know enough to utilize it and be dangerous .

Regardless, virtual machines provide a way to simulate multiple computers and I’ve done 3-tier software testing (client to app server using WCF and app server to SQL 2005 backend) to verify our framework can support both 2-tier (client –> DB) and 3-tier deployments.  Rarely used it for development, again due to speed.

Fast forward to the current time, I’d like to be able to do some coding on Windows 7; unfortunately Windows 7 is not quite sanctioned yet to be deployed, and it’s a pain to have to dual-boot.  I do have Windows 7 at home, but got way too many experimental stuff on it .  So, I’m setting up a Windows 7 VM so I can do some coding on it.

Now, nothing wrong with running the VM within VMWare, but I always find that it is a bit sluggish unless I go to full screen mode.  If I do so, it’s a bit of a pain to go back and forth between the host and the VM, and it also means that I have to do it at the host.  Ideally, I’d like to remote desktop into it (for whatever reason, I also feel remoting into a VM session makes for a snappier UI response).

However, this is not immediately possible to do without some setup; out of the box VMWare provides VNC connectivity, so you can use that but I am spoiled by remote desktop – it is just way nicer than VNC.  Of course one of the advantages of VNC is that if someone connects to it, the original don’t lose the view of the PC, so different tools for a different job.

In any case, I’d like to be able to remote desktop into my VMs – there are 2 ways to set this up, one is faster but it is considered as ‘nice’ and may cause problems with typical corporate network setups.  Let’s look at the first approach:

image

The first approach is to set up the VM setting to have it’s network adapter be a Bridged connection.  This basically sets the VM to use the host’s network card as if it were its own network card.  This also means that the VM will get an IP based on the host network’s settings (usually DHCP-based).  Essentially it brings the network connectivity of the VM to be at the same level as the host.  Now, in a corporate environment (usually domain-based), this may not be allowed, or you may have trouble with accessing the network at all if your VM is not added to the domain.  On a local (home) network, it also means it can communicate with other computers on the same network (good), but if it gets infected with a worm / virus it can also spread to the other computers (bad).

Depending on your environment, bridging may be fine and if you can do that then by setting it to Bridged mode you can then remote desktop to the VM (you have to remember to turn it on within the VM).

However, in my current situation, setting a VM network in bridged mode is not condoned and we have to set it to NAT setup.  Each VM that you spun will then get a typical internal IP address (192.168.XXX.XXX); but that means you cannot get to it from the outside.  So what to do?  The answer was provided in this post by rsa911– I’m just providing the nice UI snapshots (and also as a reminder for me on how I got it to work in the future).

In NAT mode, each VM is given an internal IP address and VMWare essentially becomes the bridge between the host and the VMs that runs in it.  Fortunately, you can do port forwarding to these internal IP address.  As detailed here, Remote Desktop uses port 3389 to listen to incoming RDP requests.  So what we need to do is forward an unused port to each VM’s port 3389 and we should be able to remote into them.  Let’s see how that’s done.

image

To do port forwarding, we need to access the Virtual Network Editor from VMWare Workstation (under the Edit Menu –> Virtual Network Editor).  The dialog above should show up – select the network adapter that is set to NAT.  Then click on the ‘NAT Settings…’ button, the following dialog will show up:

image

Click on the ‘Add’ button, and a dialog to map incoming port shows up; the dialog below is filled with the following information:

  • Listen to port 9997
  • Any TCP communication to that port, forward it to the VM with IP of 192.168.118.130 on port 3389 (default RDP port)

image

Tweak it to satisfy your setup – the host port just needs to be an unused port (in this example I use 9997), the VM port needs to be 3389 (unless you’ve changed it) and the VM IP address needs to be the IP address assigned to the VM you’re running (in Command Prompt run ipconfig to easily see this); this is what my output looks like:

image

When done, click OK and the NAT Settings dialog will show up your port forward:

image

So now I’ve set up VMWare so any incoming request to port 9997 will be forwarded to port 3389 on the VM that has IP of 192.168.118.130.  Remember that for Remote Desktop to work, you still need to make sure your VM has RDP enabled and you have users with passwords added as Remote Users.

The question is then how do you issue the remote desktop request?  Well, you use the host’s IP (or machine name) as the target, but you provide the port number as well:

image

The VMWare is hosted in my laptop (mbudimane6500) and I’m providing the port RDP should use (9997).  Remember that in a domain environment it’ll try to login as a domain user (DOMAIN_NAME\username format), so if your VM machine is not part of a domain you have to change the username to use to log in.

If you’ve done everything as mentioned above, now you can remote desktop into your VM machines in a NAT environment .  Remember also that you have to do the port forward for every VM that you wanted to remote into – each one will have a different IP address and each one will need to have a different port number.  Hope this helps others.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
Posted On Friday, November 13, 2009 8:42 AM | Feedback (23)
Wednesday, November 11, 2009
Make SQLExpress DB accessible from other computers

When I started using SQLExpress 2005, everything works on my development machine – however when I wanted to access the database from another machine (trying to access the sqlexpress database remotely) I was not successful.  I discovered the solution way back then, also through Google searches, which still yield a valid result.  However, every now and then my peers would ask me this same question again.

Thus I’m creating this blog so I can forward them to this page (instead of talking about it); it’ll also remind me of how to do it if my memory starts to fail me.

By default, SQLExpress installations does not allow remote connections, so we need to change that first.  To change it, you have to run the SQL Server Surface Area Configuration tool – as the name vaguely implied, this tool will allow you to configure SQL Server’s Surface (what gets exposed).  This tool is installed with your SQL installation (express or not); it should be located in the Microsoft SQL Server 2005 / 2008 program group, under the Configuration Tools subgroup.

When you run this, the following dialog appears:

 sac01

Select the ‘Surface Area Configuration for Services and Connections’ (as circled above).  The next dialog should appear:

sac02

Select the Remote Connections node on the tree view (as circled above); the dialog changes to the following:

sac03

As you can see, SQL Express by default does not allow remote connections (the text above it also enforces that); so we’d like to change that – select the ‘Local and remote connections’ radio button, depending on your needs you choose to use TCP/IP or named pipes or both, then click the ‘Apply’ button – an alert should show up telling you that the settings will not take effect until the database engine is restarted, we’ll do this last.

We’re not finished yet; what happens right now is that the system is set up to allow remote connections.  However, there’s another piece of service that needs to be up before we can connect to it remotely.  That service is the SQL Server Browser service.  Select the SQL Server Browser node on the left tree view, and the dialog will change to show the following:

sac04

Again, by default the SQLBrowser service is disabled, so let’s change that to Manual, click ‘Apply’ (which will enable the ‘Start’ button) then click the ‘Start’ button, which will start the service.  OK, we’re almost finished; the last step is to restart the SQL Server service itself, so let’s click on the Service node under the SQLEXPRESS and Database Engine node in the tree view.  The dialog will change to the following:

sac05

Click ‘Stop’ and then wait for the service stoppage to complete, then click ‘Start’ again.  You should be able to connect to your SQLExpress instance from another computer (if it’s the default instance, you would use computername\SQLEXPRESS as the server name).  Good luck!

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
Posted On Wednesday, November 11, 2009 4:08 AM | Feedback (0)
Friday, November 06, 2009
Putting pictures in Windows Live Writer in their original size

I guess I’m one of those people who rarely reads manual, and outside of technical documentation, I rarely read an application’s user manual.  So I’m using Windows Live Writer, and I’m trying to embed a picture in my draft blog post.  Well, whenever I do that, the picture always come in scaled down (if it’s even a tad large, like 300 pixels wide), like the picture below:

image

Well, obviously with technical and text-heavy images, scaling down is bad (can’t read much).  I can go to the HTML source, but I can’t seem to rescale the image, even when I took out the width and height property.  Pretty weird.  So how do I scale it?  Clicking on the image in Live Writer shows me the following information on the right-hand pane:

image

First off pictures that are inserted into Live Writer automatically gets treated as a clickable link.  If it’s a regular (non-text) picture, most probably that’s desirable; however in most of my cases, I’d like to put in the actual picture itself and don’t want to make it clickable.  So make sure you set the bottom-most combobox (the one under the heading Link to) to None.

On the top side of this info pane, there are 3 tabs; select the ‘Advanced’ tab and the information displayed changes to:

image

The combobox under the Size heading will also list the original size; select that and your picture now gets shown in its original size.  I’m happy ()to have found this since in some of my past blog posts I actually had to set the width/height of the picture manually in the HTML.

Also, with geekswithblogs, to set the tags to associate with your blog post, the bottom part of Live Writer has this ‘Set categories’ combobox – click on it and it’ll show you the tags that you’ve defined in your blog:

image

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
Posted On Friday, November 06, 2009 9:31 AM | Feedback (1)