Tuesday, February 28, 2012

The given key was not present in the dictionary

This can be a pretty generic error message, but one way to find out where it comes from is to look at the exception trace...

One example is that you are only checking if the dataview is nothing and not checking if it contains any rows before you filter it.

Can be confused with XAML binding error.

Wednesday, February 22, 2012

SystemParameters Screen Resolutions WPF

(From MSDN)
MaximizedPrimaryScreenHeight (MX)
Gets a value that indicates the height, in pixels, of a maximized top-level window on the primary display monitor.

FullPrimaryScreenHeight  (FP)
Gets the height, in pixels, of the client area for a full-screen window on the primary display monitor.

PrimaryScreenWidth (P)
Gets a value that indicates the screen width, in pixels, of the primary display monitor.

VirtualScreenHeight (V)
Gets a value that indicates the height, in pixels, of the virtual screen.
The virtual screen is the bounding rectangle of all display monitors. The VirtualScreenTop and VirtualScreenLeft metrics are the coordinates of the upper-left corner of the virtual screen.

WorkArea (W)
Gets the size of the work area on the primary display monitor.
The work area is the portion of the screen that is not obscured by the system taskbar or by application desktop toolbars.

My screen resolution: 1920 x 1080 pixels * 2 monitors = 3840 x 1080 pixels

(MX)   1936 x 1066
(FP)   1920 x 1028
(P)     1920 x 1080
(V)      3840 x 1080
(W)    1921 x 1051

Remote desktop to my computer: 1680 x 1050 pixels

(MX)   1696 x 1036
(FP)   1680 x 998
(P)     1680 x 1050
(V)     1680 x 1050
(W)    1681 x 1021


    Public Sub UIControllerDisplaySizes()

        MessageBox.Show("MaximizedPrimaryScreenWidth" & ": " & SystemParameters.MaximizedPrimaryScreenWidth & vbNewLine &

                        "MaximizedPrimaryScreenHeight" & ": " & SystemParameters.MaximizedPrimaryScreenHeight & vbNewLine &

                        "FullPrimaryScreenWidth" & ": " & SystemParameters.FullPrimaryScreenWidth & vbNewLine &

                        "FullPrimaryScreenHeight" & ": " & SystemParameters.FullPrimaryScreenHeight & vbNewLine &

                        "PrimaryScreenWidth" & ": " & SystemParameters.PrimaryScreenWidth & vbNewLine &

                        "PrimaryScreenHeight" & ": " & SystemParameters.PrimaryScreenHeight & vbNewLine &

                        "VirtualScreenWidth" & ": " & SystemParameters.VirtualScreenWidth & vbNewLine &

                        "VirtualScreenHeight" & ": " & SystemParameters.VirtualScreenHeight & vbNewLine &

                        "WorkArea.Width" & ": " & SystemParameters.WorkArea.Width & vbNewLine &

                        "WorkArea.Height" & ": " & SystemParameters.WorkArea.Height & vbNewLine &

                        "IsRemotelyControlled" & ": " & SystemParameters.IsRemotelyControlled & vbNewLine

                        )

    End Sub



Problem with Lync Client Evaluation Expired

If you have had the evaluation version of Lync installed, you might get an error message saying that the evaluation period has ended.

When uninstalling and reinstalling Lync client, the problem persist.

To get around this, navigate to the registry HKLM - Software - Microsoft - Communicator and delete the Registration folder. Then reinstall Lync client

Tuesday, February 21, 2012

Custom DependecyProperty with Double

Use Nothing when setting default value on a Double in your DependencyProperty


   Public Shared ReadOnly MaximizedPrimaryScreenHeighttProperty As DependencyProperty =
        DependencyProperty.Register("MaximizedPrimaryScreenHeightt", GetType(Double), GetType(Window1), New PropertyMetadata(Nothing))

    Public Property MaximizedPrimaryScreenHeightt() As Double
        Get
            Return DirectCast(GetValue(MaximizedPrimaryScreenHeighttProperty), Double)
        End Get
        Set(ByVal value As Double)
            SetValue(MaximizedPrimaryScreenHeighttProperty, value)
        End Set
    End Property

Monday, February 20, 2012

Check LyncClient.GetClient()

Check if Lync client is running on the users computer.

Required DLL's:
 Microsoft.Lync.Model.dll and for some reason Microsoft.Office.Uc.dll might be required for the GetClient not to throw a TypeInitializationException.



LyncClient.GetClient() calls the EnsureOI() method.



private static void EnsureOI()
{
if (s_officeIntegration == null)
{
try
{
if (!IsUISuppressed() && !IsRunning())
{
throw new ClientNotFoundException("The host process is not running", null);
}
s_officeIntegration = (UCOfficeIntegration)
Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("...")));
}
catch (COMException exception)
{
throw GetOCOMException(exception);
}
}
}





//Test if Lync is running and get object
try
{
   _lyncClient = LyncClient.GetClient();
   startClient();
}
catch (ClientNotFoundException ex)

{
   throw new Exception(ex.InnerException.ToString());

}
catch (TypeInitializationException ex)

{
   throw new Exception(ex.InnerException.ToString());

}
catch (NotStartedByUserException ex)

{
   throw new Exception(ex.InnerException.ToString());

}
catch (Exception ex)

{
   throw new Exception(ex.InnerException.ToString());

}