Dynamic Code Blocks

Microsoft Dynamics GP & .NET technical Blog by Tim Wappat

Team Foundation Server (TFS) -The underlying connection was closed

image
Having build and upgraded Team Foundation server from 2010 to 2013, SQL Sever and Sharpoint Foundation 2013, running on VMWare ESX,  the team found very frequent and random like connection dropped problems, most frequent being:
  • connection that was expected to be kept alive was closed
  • The underlying connection was closed

This happened trying to check things in, or other source tracking related activities against Team Foundation Server.

The hunt was on the the cause, a week of investigation (on and off), heading off looking at the IIS settings, checking settings for WCF, looking for possible max connection limits, working pools and recycling logs etc.

Also investigated a post regarding network interface card (NIC) off loading and to switch it off on virtual boxes (I’m not convinced by that).

Solution

For others in a similar position, I present our solution, the static IP address that was assigned to the server had accidentally had a a printer assigned to it too. So whenever the user came in to work and put the printer on (not every day), we would experience these problems, for a bit, until the printer went off again. All due to the duplicate IP address.

How to make GP company login text boxes longer

In the blog post series by David Musgrave, he shows how to customise the GP company login boxes, to make them long enough to see very long company names in full. David uses Dexterity in the third part of the series. However in the latest he attempts to do the same using an addin, albeit he “cheats” by passing in the SanScript. Note this is not a supported method.
By using the Continuum COM library to allow .NET code in the Dynamics GP Visual Studio addin to pass SanScript through to the GP we CAN do it, see how I did it!

The original article can be found here:

image

Customising the Company Login window series Part 4 - Visual Studio Toolsby David Musgrave

So David had a problem getting it working, I had Visual Studio open on my Addin project, so I gave it a go.

Make a reference to the Continuum

This is a COM object in, so go to your project reference and search for “contin” and then add the reference. Ensure you marry the version number with the version of GP you are using.

image

Store the script in a project resource

Under the project settings, you can store resources. This is a good place to put your scripts as it deals with line feeds and keeps them in an intact form for future editing.

Go to the resources tab of the project properties, create a new resource and paste in the script provided by David. We are going to use the .NET code to run the script, so we don’t need to put it in a procedure, only take the fragment that does the deed. Name the resource LoginResizeScript

image

Add event handler

Now when the company login window is opened we want to execute the script to resize the text boxes on that window. So to me it seems like a good plan to add and event handler to the company switch form. Now go to your GPAddin.vb and add and event handler like this for the company switch form.

Sub Initialize() Implements IDexterityAddIn.Initialize
'You should add code to only execute once in lifetime
AddHandler Microsoft.Dexterity.Applications.DynamicsDictionary.OpenSwitchCompanyFormProcedure._Instance.InvokeAfterOriginal, AddressOf DoLoginResize

End Sub

Deal with the namespaces

Important as the project reference messes you up!

Imports DynamicsGP = Microsoft.Dexterity.Applications.Dynamics

Execute the script

So next the script needs to run in response to the event firing on the Switch Company event handler. Add the following to your GPAddin.vb .

The SanScript is now held in a project resource we can reference by My.Resources.Resources.LoginResizeScript so we push this into the ExecuteSanscript method.

Public Sub DoLoginResize(sender As Object, e As EventArgs)
Dim CompilerApp As New Dynamics.Application
Dim CompilerMessage As String = Nothing
Dim CompilerError As Integer
' Execute SanScript in Dynamics GP
CompilerError = CompilerApp.ExecuteSanscript(My.Resources.Resources.LoginResizeScript, CompilerMessage)
If CompilerError <> 0 Then
Windows.Forms.MessageBox.Show(CompilerMessage)
End If
End Sub

Resulting resized controls – it works!

image

And hey it works from VB.NET too! I love Visual Studio and Dynamics GP!

Solved having to click twice to drop a DataGridViewComboBox

The default behaviour of a drop down combobox in a datagridview is for it to require one click to activate it and another to actually drop it down.

Users can’t get this paradigm and so prefer for it to activate immediately on clicking anywhere on the cell. I have seen many solutions on Stackoverflow for this, but most require the arrow part of the cell to be clicked, not working if the user just clicks the cell in the middle. 

image

I found the following solution to work for me:

Private Sub DataGridView1_CellClick(sender As Object, e As DataGridViewCellEventArgs) _
Handles DataGridView1.CellClick
If (e.ColumnIndex > 0) And e.RowIndex <> -1 Then
With DirectCast(sender, DataGridView)
If .Columns(e.ColumnIndex).Name = "PalletType" Then
.CurrentCell = .Rows(e.RowIndex).Cells(e.ColumnIndex)
.BeginEdit(True)
DirectCast(.EditingControl, _
System.Windows.Forms.DataGridViewComboBoxEditingControl).DroppedDown = True
End If
End With
End If
End Sub

This makes certain the column is not a header cell, and only does it for the column with the name “PalletType”

I also have the DatagridView set to EditOnEnter for the Edit mode.

image