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());

}

Thursday, June 23, 2011

Missing DVD device drive when installing Server 2008 x64 or Windows 7 x64

I have had major problems when trying to install Server 2008 x64 or Windows 7 x64 whene it tells you that a DVD driver is missing.

Many options online to try to resolve this issue has been found, but none of them works.
Some are related to the raid configuration, some related to bad download of the OS and so on... but the real probelm is from Microsoft itself.

Exactly what it is, might be unknown, but the problem only occurs when you try to install a 64 bit version of Server 2008 R2 without SP 1 or Windows 7 without SP1.

All other versions are fine, so if you have Server 2008 SP2 or R2 with SP1 (which you can download now from Microsoft), go ahead and enjoy a problem free (or one less error) installation.

Sunday, May 1, 2011

Passing ByVal acts like ByRef?

Did u know....
That regardless if you specify ByVal in the method that you are passing in a parameter, if the parameter is an object reference, it will still be passed in as a ByRef.

Duhhh... does many say, but if you are coding a lot, this might leave your brain to malfunction when trying to debug...

Yes, you should always look at the parameters being passed from the caller and not just look at the called method.

Just see this as a pointer :)