How to network host to guest in Microsoft Virtual Server 2005 R2?

May 18th, 2006 No comments

The official release of yet another discovery of server virtualization technologies is available for *FREE* download on Microsoft’s web site. Microsoft Virtual Server 2005 R2 caught my eyes soon in a way that I am almost done with transferring all my virtual machines from VMWare to this great product. I have also installed it on my laptop and since my laptop has no physical net connection, I had quite a hard time to configure networking connection between guest and host operating systems. It is fairly easy to do so in VMWare by utilizing VPN connection (Host only –VMNet1), but in virtual server 2005 ,you must follow some steps to properly setup the connection.


 


 1)Log in to the host computer using an administrator account


 2)Install Microsoft Loopback adaptor on the host OS only.For more information on how to install Microsoft Loopback adaptor check this link


 3)Make sure Virtual Machine Network Services is checked in Microsoft Loopback adaptor     


 4)Set Internet Protocol (TCP/IP) in the host  to use an static IP address from a non-routable range like 192.168.x.y



Note: The tricky part is here. First of all x in host IP address must be exactly same as x in guest IP address (You should set the guest OS to use an static IP address too, you will see it later in this post). Leave the subnet mask to be 255.255.255.0 on the host and do not set a value for default gateway. The most important part is that if your primary Ethernet card or any other adaptor (in my case, my VMWare VPN) is using x ,then you won’t be able to connect host to guest. In that case you must choose a different value for x.


 5)Set Internet Protocol (TCP/IP) in the guest to use an static IP address from a non-routable range like 192.168.x.z. As I mentioned above x must be same as the host ,and again no default gateway


 6)file and printer sharing must be exempted from the guest’s firewall (if you are planning to remote desktop to the guest computer from the host ,do the same for remote desktop as well)


 7) Go to virtual server administration console and change your virtual network to use Microsoft Loopback adaptor . If the option is not there uninstall/reinstall the Virtual Server 2005. restart the guest operating system and you should be good to go!

Categories: Uncategorized Tags:

Programmatically resizing IFRAME height

April 30th, 2006 No comments

Have you ever tried to use “Page Viewer Webpart” in sharepoint ? There is a big problem setting the height for this webpart when the page, that is loaded in its iframe, varies in height. In some cases scrollbars appear even if the height is set in webpart property. In respond to a client request, I have recently developed a WSS template that contains a web part which iterates through a pre-defined/pre-populated document library, looking  for default.aspx or default.html and renders that page in an IFRAME. I had to dynamically resize the document library in run time according to the height of the page it points to. My solution contains a java script file named “iFrameResizer.js” that is set to be “Content” of my web part and a little bit of code in my web part to link to this script file to my web part.


 


//—————————————————————–


//iFrameResizer.js


//—————————————————————–


/* This function is used to adjust the iframe height to its content */
function iResizer(iframeID,iframeName)
{


     moz=document.getElementById&&!document.all
     mozHeightOffset=20
    document.getElementById(iframeID).width=”100%”
    document.getElementById(iframeID).height=window.frames[iframeName].document.body.scrollHeight+(moz?mozHeightOffset:0)
}


 



Then in the constructor of  web part I added an event handler to the PreRender event that loads “iFrameResizer.js” onto the page on prerendering  :


 


using System;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WebPartPages;


namespace DevHorizon.Sharepoint.iFrameWP
{
 ///
 /// Description for Frame.
 ///
 [DefaultProperty(“Url”),
  ToolboxData(“<{0}:Frame runat=server>”),
  XmlRoot(Namespace=”DevHorizon.Sharepoint.iFrameWP”)]
 public class Frame : WebPart
 {
  private const string defaultUrl = “shared%20documents/default.htm”;
  private string url = defaultUrl;


  // Used for the linked script file
  private const string iFrameResizerFileName = “iFrameResizer.js”;
  private const string iFrameResizerIncludeScriptKey = “iFrameResizerIncludeScript”;
  private const string IncludeScriptFormat =@” language=””{0}”” src=””{1}{2}””>”;



 
  [Browsable(true),Category(“Miscellaneous”),DefaultValue(defaultUrl),WebPartStorage(Storage.Personal),FriendlyName(“Url”),Description(“URL Property”)]
  public string Url
  {
     get
     {
       return url;
      }


   set
     {
      url = value;
     }
  }


 


  // Contructor
  public Frame()
  {
      this.PreRender += new EventHandler(WebPart_Frame_PreRender);
  }


  //Function which will register the linked file script


 


  private void WebPart_Frame_PreRender(object sender , System.EventArgs e )
  {
       string location = null;
        // Make sure that the script was not already added to the page.
        if (!Page.IsClientScriptBlockRegistered(iFrameResizerIncludeScriptKey))
          {
           location = this.ClassResourcePath + “/”;
          // Create the client script block.
          string includeScript = String.Format(IncludeScriptFormat, “javascript”, location, iFrameResizerFileName);
          Page.RegisterClientScriptBlock(iFrameResizerIncludeScriptKey, includeScript);
         }


  }


 


  protected override void CreateChildControls()
  {
   Literal lit = new Literal();
   Guid gid=Guid.NewGuid();
   string iframeID=”ExxoniFrameWPId” + gid.ToString();
   string iframeName= “ExxoniFrameWPName” + gid.ToString();
   lit.Text = “”;


   this.Controls.Add(lit);


  }
 
  protected override void RenderWebPart(HtmlTextWriter output)
  {
      try
       {
          RenderChildren(output);
        }
     //display diagnostic error information if exception occurs
     catch(Exception ex)
      {
        output.Write(”


“);
        output.Write(“Exception Type: ” + ex.GetType().ToString() + “
“);
        output.Write(“Exception Message: ” + ex.Message + “


” );
        output.Write(“Stack Trace:” + ex.StackTrace.Replace(”
“, “
“));
        output.Write(“
“);
   }


  }
 }
}


 


There is one thing to remember:


I assume that iFrameResizer.js has been already added to the solution as “content” and is deployed to wpresources (or _wpresources if web part is installed in GAC). You have to add the following code to Manifest.xml

Categories: Uncategorized Tags:

Vague errors working with WSE 2.0 Direct Internet Message Encapsulation

March 28th, 2006 No comments

Yesterday, I was just trying to attach a DIME attachment to my soap message and send it to a WSE 2.0 enabled web service resides on my virtual server (VMWare). I was getting “Message Expired” or “An error was discovered processing the header” all the time. It was obvious that this was happening on the client since soap request was not reaching to the server (I was monitoring the server by MSSOAPTrace and nothing was there). After I did a lot of changes to the client I came to realize that Date and Time on the server was out of synch with client. That was all about it.

Categories: Uncategorized Tags:

Custom site definitions VS Custom templates

March 24th, 2006 No comments

When it comes to sharepoint deployment, site definitions are preferred the most. People often rely on site definitions more than custom templates. I agree that it gives you more control on every thing, but it is not always the best solution and it truly depends on what you want to accomplish. In this article I would try to give you a high level understanding of both solutions and you got to decide which one suits you the best.


1) Custom site definitions:


Advantages:



  • Data is stored directly on the Web servers, so performance is typically better.
  • Full control over look and feel of site
  • ASPX pages can be defined as ghosted modules. Ghosted files are not copied into site content and are directly read from site definition (They are stored in the directory in which site definition exists) and cached on the web server. Any changes to these files are automatically propagated to all sites which are based on the site definition. For example add “ this is a changes” to default.aspx page in one of the site definitions (e.g: STS). You will see this in all default.aspx pages of the sites which are based on the site definition. As soon as you make a minor change to a ghosted file through Front page it becomes unghosted and added to the site’s content.
  • A higher level of list customization is possible through direct editing of a SCHEMA.XML file.
  • Certain kinds of customization to sites or lists require use of site definitions, such as introducing new file types, defining view styles, or modifying the drop-down Edit menu.

Disadvantages:



  • Customization of site definition requires more effort than creating custom templates.
  • Any error or inconsistency in site definition related xml files prevent site definition from working.
  • Changes to site definitions must be done one by one and after each change you must restart IIS and check to see if your change has not broken anything.
  • Most of site definition files are xml based and altering them requires a good understating of xml elements and attributes used in these file. However share point SDK fully covers them.
  • I tried using ghosting with an HTML page , but it did not work because HTML pages are cached differently than ASP.NET pages.
  • It is difficult to edit a site definition after it has been deployed.
  • Doing anything other than adding code can break existing sites (especially deletes).
  • Users cannot apply a SharePoint theme through a site definition.
  • Users cannot create two lists of the same type with different default content.
  • Customizing site definitions requires access to the file system of the front-end Web server.

2) Custom templates


Advantages:



  • Custom templates are easy to create.
  • Almost anything that can be done in the user interface can be preserved in the template.
  • Custom templates can be modified without affecting existing sites that have been created from the templates.
  • Custom templates are easy to deploy. All you need to do is to upload them to the template gallery of the site you wish to derive sub-sites from.

Disadvantages:



  • Custom templates are not created in a development environment.
  • They are less efficient in large-scale environments.
  • If the site definition on which the custom template is based does not exist on the front-end server or servers, the custom template will not work.
  • Top-level sites cannot be created based on custom templates.

Categories: Uncategorized Tags:

Working for significance

March 5th, 2006 No comments

Effective 20th of March, I am no longer working for CGA Canada and instead I will start my new career as system analyst (on contract basis) at ExxonMobil. I am quite excited to get this job as it will allow me to literally use my skills to make a real contribution and more rapidly prototype my new ideas. CGA was a great experience, but things started to move so fast in both my personal and professional life in a way that I could not go wrong. I guess I’ve decided NOT to work for success alone, but for success and significance simultaneously.

Categories: Uncategorized Tags: