Welcome to MSDN Blogs Sign in | Join | Help

NicolTIP#007: What to do when you no longer can run macros in Outlook 2007

I am quoting information from [http://blog.tjitjing.com/index.php/2007/03/things-i-can-and-cannot-get-to-work-in.html] because I tumbled in this issue and forgot to "just" restart Outlook :^)

Whenever I went in to Tools - Macro - Macros, selected my macro and hit run I would end up in the Visual Basic editor with an error message saying “The macros in this project are disabled. Please refer to the online help or documentation of the host application to determine how to enable macros.”
I went in to Tools - Macro - Macro Security and first changed from the default “Warnings for signed macros; all unsigned macros are disabled” to “Warnings for all macros” and finally to “No security check for macros” but I still could not get the macros to run.
In spite of a lot of Googling I found nothing. Then I realized I hadn’t tried trick no 1 in the book: Restart Outlook. And of course that was the solution
(Note to Microsoft: Please add a “Outlook needs to be restarted” message. Note to myself: Don’t be so stupid next time around)

A good thing in Outlook 2007 is that I no longer get the “A program is trying to access e-mail addresses you have stored in Outlook. Do you want to allow this? … Allow for x minutes”. I assume they have gotten rid of this annoying message and replaced with some security feature that does not require user intervention.

Posted by NicolD | 0 Comments

NicolTIP#006: how to show previous and next item using LINQ

I had a table on SQL 2005 I am accessing it via LINQ. I had to select an item via a “where” condition (see below).

var item = (from snap in adc.Snapshots
      where snap.file == image
      select snap).First();

The problem was that I needed to identify the previous item and the next item too because we had to show them on a web page. Talking with some collgues of mine we found the following way that looks quite smart:

var previous = adc.Snapshots.OrderByDescending(s => s.InsertDateTime).Where(s => string.Compare(s.file, image) < 0).FirstOrDefault();
var item = adc.Snapshots.OrderBy(s => s.InsertDateTime).Where(s => s.file == image).SingleOrDefault();
var next = adc.Snapshots.OrderBy(s => s.InsertDateTime).Where(s => string.Compare(s.file, image) > 0).FirstOrDefault();

Posted by NicolD | 0 Comments
Filed under: ,

NicolTIP#005: How to show the same content in two ore more positions using master page in ASP.NET

To write a web site and give to the entire site a coherent “look” with ASP.NET and master pages is very easy and productive. In brief, into the master page you need to put “placeholders” using the tag <asp:ContentPlaceHolder/> and into the content page, you can map real content with contenplaces (more information).

Sometime can be required to put the same content in more places, an example is the “title” field that you could put both in the header\title field and into a H1 tag into the body.

This means, starting from the following content page:

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Root.Master" AutoEventWireup="true" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Title" runat="server">This is my title</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MyContent" runat="server">This is my content</asp:Content>

To obtain the following html output:

<html>
<head>
    <title>This is my title</title>
</head>
<body>
<h1>This is my title</h1>
This is my content
</body>
</html>

The easy way I found is shown in the following master page:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Root.master.cs" Inherits="NicolD.MasterPages.Root" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title><asp:ContentPlaceHolder id="Title" runat="server"></asp:ContentPlaceHolder></title>
</head>
<body>
<h1><span id="TitleOnPage" runat="server"></span></h1>
<asp:ContentPlaceHolder id="MyContent" runat="server" Visible="false"></asp:ContentPlaceHolder>
</body>
</html>

the true secret is in the master page’s code behind:-), where I filled “TitleOnPage” with “Title” place holder content.

public partial class Root : System.Web.UI.MasterPage
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        this.Page.LoadComplete += new EventHandler(Page_LoadComplete);
    }

    private void Page_LoadComplete(object sender, EventArgs e)
    {
        LiteralControl lc = (LiteralControl)Title.Controls[0];
        TitleOnPage.InnerText = lc.Text;

    }

}

NicolTIP#004: seven new keyboard shortcuts for Window 7

I love keyboard shortcuts and W7 add some new really cool…

Managing Your Windows. Windows 7 simplifies document and program management by allowing you to “dock” a window or manipulate its size with one mouse maneuver or a simple keystroke. To dock your window on one half of the screen, drag it to the left or right and it will change its size to fit that half of the screen. To manipulate the vertical size of a window, you can drag the window to the top to maximize it, or double-click the window’s top or bottom border to maximize it vertically while keeping the same width.

You can also perform all of these functions with keystrokes:

  • Windos key+Left Arrow and Windos key+Right Arrow dock to half the screen
  • Windos key+Up Arrow and Windos key+ Down Arrow maximize and minimize
  • Windos key+Shift+Up Arrow and Windos key+Shift+Down Arrow maximize

and restore vertical size.

 

Multi-Monitor Window Management. Windows 7 makes using multiple monitors as convenient as it should be. When you’re working multi-monitor, use the keyboard shortcuts Windos key+Shift+Left Arrow and Windos key+Shift+Right Arrow to move windows from one monitor to another. The rearranged window will keep its relative position to the top-left origin on the new monitor.

 

Project Your Display With Ease. Plugging in a projector and projecting your display is a snap with the Windows 7 driver display utility, displayswitch.exe. Simply hit Windos key+P and you’ll be rewarded with the following easy-to-navigate pop-up window. By hitting your arrow keys (or Windos key+P) you can switch through multiple display settings, such as “clone”, “extend” or “external only”.

 

Live Clutter-Free. We live with enough clutter in our lives. Windows 7 gets rid of all the superfluous windows behind your active window. Just hit Windos key+Home to minimize all inactive windows. To restore the windows when you’d like them, just press:

  • Windos key+Home again

 

Help the Help Desk Help You. Solving problems unique to a machine can be an arduous task for both the end-user and the help desk. That’s why Windows 7 introduces the Problem Steps Recorder, a screen-capture tool that allows the end-user to record the problems they’re having step-by-step. It’s as simple as hitting “record” then adding in comments as needed. A HTML-based file is converted to a .ZIP folder, which is easily passed on to the help desk. The program is accessible from the Control Panel under “Record steps to reproduce a problem” or run psr.exe from Explorer.

 

Aero Peek Your Desktop. A lesser-known versatile tool on the taskbar introduced with Windows 7 is the Windows® Aero® feature, “Aero Peek” – the small rectangle in the lower right hand corner. It allows you to peek at any of the icons or gadgets on your desktop. The keyboard shortcut Windos key+Space performs the same function.

 

Shuffling Through Program Windows. If you’re running a number of files from the same program, such as multiple documents in Microsoft Word, Windows 7 allows you to switch through these windows with ease. Simply hold down the Ctrl key while repeatedly clicking the icon from the taskbar. Each click will change the window to the next in the sequence, in the order that you opened them.

Posted by NicolD | 1 Comments

NicolTIP#003: How to install Windows SharePoint Services 3.0 Tools - Visual Studio 2008 Extensions, Version 1.2 on Windows Vista

If you try to install Windows SharePoint Services 3.0 Tools - Visual Studio 2008 Extensions, Version 1.2 on Windows Vista, you will get an error message telling you that you have to install Windows SharePoint Services 3.0 in order to install the tools. Windows SharePoint Services 3.0 (WSS 3.0) doesn't support non Windows Servers OS, so it's not possible to install WSS 3.0 on Windows Vista, which means you will not be able to install VS 2008 Extensions on your development machine.

This happens because setup just checks on the registry the presence of a specific key. To avoid this behavior and install these extensions on Vista (but should work on XP as well) just write the following key on your machine registry:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0]
"Sharepoint"="Installed"

NicolTIP#002: Create a manifest.xml extracting content type(s) and columns from a site using Sharepoint Designer

Step to extract a content type and columns to CAML (XML)

  • Create you content type and columns in the web UI.
  • Create a list/library item using you new content type.
  • Load up Sharepoint Designer to the site where you created you item.
  • From the File menu, click Export -> Personal Web Package.
  • In the export web package window select the list/library where your create the item using the new content type and click add.
  • Save the package to your local drive.
  • Next browse to where you saved the file and rename it from .fwp to .cab.
  • Extract manifest.xml to your local drive.
  • Load the file up in your favourite XML viewer (might take a second or two it can be a large file).
  • Navigate to the UserLists/Field node (Solution/UserLists/Fields).
  • within this node look for your field, you will be able to see the CAML that describes your field.

NicolTIP#001: edit easily your machine's HOST file

Edit the HOST file in Vista is difficult than ever, thanks to UAC. If you’re a geek that changes HOST file daily this can be a bit frustrating. I circumnavigated the difficulty with a shortcut.

  1. Right click on the folder you want to place the hyperlink (i.e. desktop) and select “new->Shortcut”
  2. As location of the item type: notepad.exe C:\Windows\System32\drivers\etc\hosts
  3. As Shortcut name type “Edit HOST file (as administrator)”
  4. right click on the new shortcut just created and select “properties”
  5. Select “Advanced”
  6. Select “Run as Administrator”

Now, if you need to edit the HOST file (and folder where you put the shortcut is indexed by vista search) just click on start button and type “edit host”

Edit Machine HOST file

Posted by NicolD | 1 Comments
Filed under: , , ,

Chrome OS?

Yesterday evening I had the opportunity to read in detail the document that describe Google Chrome features. Interesting is that if I read "O.S." each time in the document appairs the word "browser" all the document continues to have sense. Very, very interesting:-)

Posted by NicolD | 0 Comments
Filed under:

Polipo Matico

PolipoMatico is a Windows Vista sidebar gadget that allows to retrieve and show italia traffic infos from octotelematics web site (www.octotelematics.it)

image

Why
Because traffic in Italy is a serious topic, and because we like to be at home, at the end of the day, with less stress as possible:-)

Usage
Just install the gadget, and add it to the sidebar. Main commands:

  • Mouse wheel: zoom in and out
  • Use the orange icon to select "rotate" or "drag" mode
  • to rotate or drag, just click and drag the image
  • double click: reset image position


Supported Areas
Roma - GRA (Grande Raccordo Anulare)

 

Download it from CodePlex: Polipo Matico

How to provide a context sentitive help to your WPF application

I found the following (and very) interesting post where is well described how to provide your windows presentation fundation client application with a context sensitive help. Chek it out!

http://blogs.msdn.com/mikehillberg/archive/2007/07/26/a-context-sensitive-help-provider-in-wpf.aspx

Posted by NicolD | 0 Comments

Win32 Application contextmenu piloting (UI Automation)

I just developed a PoC where I demonstrated to my customer how is feasible to integrate and manipulate a Win32 application (Remedy Client in my case) into a CCF (Customer Care Framework) client application.

In this context I had some problem in piloting context menu. the couple of link below give much information.

My main takeways:

  • standard context menu class name is "#32768"
  • usually context menu send a WM_COMMAND message to the application window with an ID that trigger the operation
  • when you successfully selected the context menu window (you have the HWND):
    • you can choose the menu item via WM_KEYDOWN/VK_DOWN messages
    • you can activate the menu item via a WM_KEYDOWN/VK_ENTER message

Links that saved my day:

Posted by NicolD | 0 Comments

WPF: How to embed an Icon in an Assembly

You can easily integrate resources in your Windows Presentation Foundation application by using the WPF designer for Visual Studio and "pack:" URI scheme provided by XAML to reference resources in your application's XAML.

for more information have a look to MSDN article.

Posted by NicolD | 0 Comments
Filed under:

How to access Hyper-V (RC0) machine (workgroup) from Vista SP1 joined to a domain

Step 1: Install this update to enable remote management of a Windows Server 2008 computer running the Hyper-V RC0 role

Step 2: If the server is either a member of WORKGROUP or is in a different domain that is untrusted by the client, then the connection from the server to the client used to return asynchronous results is created as an Anonymous connection. An anonymous connection fails with either the 0x80070005 error or the 0x8007000e error unless Anonymous connections are given the DCOM Remote Access permission on the client. The following steps grant DCOM remote access permissions from the server to the client in this scenario.

    1. Click Start, click Run, type DCOMCNFG, and then click OK.
    2. In the Component Services dialog box, expand Component Services, expand Computers, and then right-click My Computer and click Properties.
    3. In the My Computer Properties dialog box, click the COM Security tab.
    4. Under Access Permissions, click Edit Limits.
    5. In the Access Permission dialog box, select ANONYMOUS LOGON name in the Group or user names box. In the Allow column under Permissions for User, select Remote Access, and then click OK.

Step 3: from command prompt execute the following command:

  • cmdkey /add:yourhyper-vmachine /user:hyper-vdomani\administrator /pass:hyper-vadministratorpassword

in example:

  • cmdkey /add:srv04 /user:srv04\administrator /pass:123.password.123
NOTE: use netbios name (i.e. SRV04) and not FQDN name (i.e. SRV04.myintranet.local)
Posted by NicolD | 1 Comments
Filed under: ,

How to use Hyper-V with a wireless network connection

Hyper-V, the fantastic Windows Server 2008 new feature have a small limit I discovered when on my "home/handmade server:-)" I tried to use it. It doesn't manage wireless networks. This is "by design", as clearly described by Ben Armstrong in his blog. This absolutely make sense because Windows Server 2008 and Hyper-V is a server oriented product.

Despite of this, there are scenarios I can define "consumer" or "Lab" oriented where allow to Hyper-V to interact with a wireless network can be required. The scenarios list include:

  • A test server at home connected via wireless to both Internet and other home PCs via a SOHO router (my scenario :-)
  • A server machine used on a live/conference demo connected to the speaker's PC via wireless 

For these scenarios, we can identify following connectivity requirements:

  1. to allow to guest machine (on Hyper-V) to access to Internet
  2. to allow to guest machine to access to other machines connected to wireless LAN
  3. to allow to other machines connected to the wireless LAN to access to guest machine
  4. to allow to guest machine to be exposed and accessed from Internet

The great Ben's post on this topic, address just the scenario (1) leaving other not covered. Objective of this post is to show a configuration that allow to address all above requirement in 15 minutes or less:-)

--

Well, Hyper-V allows to create "Internal Virtual Networks" (IVN). These IVN are networks visible from both HOST and GUEST operating systems. In example if I have an internal virtual network called "RoI" (Route over Internet:-) on my host machine (i.e. SRV04.local) and the this network is shared with 3 guest machines (GUEST01.local, GUEST02.local, GUEST03.local), I'll have a "virtual" network topology as shown below:

image

In order to create a new virtual internal network switch you have to:

  1. Open the Hyper-V Manager and select your server.
  2. Select Virtual Network Manager... from the action pane (on the right).
  3. Select New virtual network and choose to Add an Internal network.
  4. Give the new virtual network the name you want hit OK.

Because SRV04.local have a wireless network card too, SRV04.local now have 2 network cards. Through this second network card, it is able connect to wireless network (WIRELESS) that allows it to interact with both other PC connected via wireless and to Internet.

image

Now, in order to allow to GUEST machines to interact with both machines connected to wireless LAN AND Internet we can enable HOST machine (SRV04.local) to act as a router.

Windows Server 2008 have a standard role called "Network Policy and Access Service" that can be activated to allow this kind of scenario.

Before to proceed, in order to simplify the discussion, let's assume to use following network configuration:

WIRELESS LAN

  • IP Range: 192.168.1.x (1<= x <=255)
  • Subnet Mask: 255.255.255.0
  • DNS == Default Gateway == 192.168.1.1
  • Wireless LAN is private and router act as a NAT to allow local machines to access Internet.

RoI LAN

  • IP Range: 192.168.2.x (1<= x <=255)
  • Subnet Mask 255.255.255.0
  • DNS: 192.168.1.1
  • Default Gateway: 192.168.2.6 (SRV04 machine on RoI LAN!)

SRV04

  • IP on Wireless LAN: 192.168.1.6
  • IP on RoI LAN: 192.168.2.6

 image

Steps required to allow GUEST01.local to access to Internet are following:

  • enable and configure "Network Policy and Access Service" on SRV04.local
  • add a static route on "default gateway" router

 

Step1: how to configure/enable "Network Policy and Access Service"

From Server Manager, select "Add Role".

Select "Network Policy and Access Service", then click Next.

Capture01

Select "Remote Access Service" and "Routing" then click Next.

Capture02

Select "Custom Configuration" then click Next.

Capture03

Select "LAN Routing only" then click Next.

Capture04

when finished, select "Start Service" on server manager.

Capture05

 

Step 2: how to configure your default gateway router

Previous configuration is not enough to allow routing because you still need to say to your router that addresses 192.168.2.x must be forwarder to SRV04.local machine. You can obtain this adding a static route on your router. Almost every SOHO router of €50 or more is able to do this, please refer to your router manual to discover how to do this.In example, at home, I have a Netgear toy that shows the following page

Capture06

In our example have to add a route to 192.168.2.0 mask 255.255.255.0 through 192.168.1.6

And that's all! Now your guest machine can access to Internet. The cool think is that with this configuration, and thanks to your cheap:-) router too, someone from Internet can access to a service based on your GUEST machine. In example, if you have an IIS on GUEST01.local and you want to show it on Internet, you can use the port forwarding option of your router with following parameters:

  • Service/Port: 80
  • Server IP Address: 192.168.2.10

Again for more information on port forwarding please refer to your router instruction manual.

This configuration still doesn't allow:

  • Other machines on your wireless LAN to access to GUEST01.local
  • GUEST01.local to access other machines on your wireless LAN

This because machines on your wireless LAN have as default gateway 192.168.1.1 and the router is not smart enough to understand that 192.168.2.x addresses must be routed to SRV04.local. The easy solution is to add a static route on each machine connected to the wireless LAN. You can achieve this adding a static route via command prompt with the following instruction:

  • route ADD 192.168.2.0 MASK 255.255.255.0 192.168.1.6

Remember that this action, on Vista, requires elevation.

Thanks to Marcello "router" Formica for the fundamental help:-)

Posted by NicolD | 1 Comments
Filed under: ,
More Posts Next page »
 
Page view tracker