So Web Application projects have this great new feature that allows you to use an XML Transform file to merge settings into your Web.Config file based on the build configuration.  For example, if you have a Release build configuration you might want your connectionString section to point to a production server instead of your development server.  See this link for more information on Web Config Transforms.

This is a really cool feature and it is possible to use this with non-web application projects.  You can configure your project file to support this very easily.  You do need to insert some XML into your csproj file but it is really lightweight.

First, Add an App.config file to your project if you do not already have one.

Next, close Visual Studio and open your *.csproj file in notepad.

Go to the very end of the file and insert the UsingTask and Target sections directly above the </Project> closing tag. 

 

Now find the section that has your App.config file include.  It will likely be in a <None /> tag.  Replace that tag with the following code. (Include a App.CONFIGURATION.config file for each build configuration you use.

Save your csproj file and open it up in Visual Studio again.

image

Now when you build your solution/project the XML Transforms in your App.CONFIGURATION.config file will be merged at build time.

I had to build a small configuration screen for an over-the-internet printing solution for Microsoft Dynamics Ax.  The application has an image that I want the user to click with either the left or right mouse button to open the context menu.  This menu allows the user to start or stop the print engine service.

image

Left or right clicking opens the context menu.

image

Here is the XAML for the Image with Context Menu.

Note: MVVM Commanding is not used here for simplicity of this post.

In this XAML snippet I named the Image and consumed the MouseLeftButtonUp event on the Image.  I also added the context menu to the Image control and named the ContextMenu.

The code behind looks like this:

In this code, PlacementTarget indicates the UIElement that the context menu will pop out from.  In this case we just use the Image element itself as passed in to the event handler via the sender argument.

Next, you simply set IsOpen to true and the context menu will be displayed over the PlacementTarget.

So last week I attended Convergence 2011 in Atlanta to prepare for Dynamics AX 2012.  I attended a few interactive discussions and met some folks that made some rather wild claims that I knew for a fact were wrong.  I advised them that they were probably missing something or there was a problem with their installation / database / or code.

The claim was that there is a 2 or more second authentication delay when logging on to Dynamics Ax from the AIF (and others claimed from the Business Connector as well).  Someone stated that it took them 5 hours to import 30,000 sales orders via the BC.  I import a heck of a lot more data then that on a routine basis and I am confident I could import 30k sales order in less than 2 mins.

The proof that they are wrong.

To prove this I wrote an application that logs on to AX and then off of AX and times the process with the Stopwatch class.  The system running AX is a Dynamics AX 2009 SP1 installation on a Dell i7 920 with 12G of RAM.  AOS, App files, and DB (SQL 2008R2 with 4GB of ram allocated to SQL) all run on the same machine.  So this is a basic low end developer workstation running everything.  Your production servers should run circles around the performance of my test machine.

Here are the results:

I ran the loop to logon and logoff 100 times.  You will see the first call takes 220ms and each subsequent call is at about 14ms.  This is a far cry from the 2,000+ ms claims from the interactive discussion at Convergence.

Start time: 0
sessionId: 5
Stop time: 220
Elapsed time: 220

Start time: 220
sessionId: 6
Stop time: 237
Elapsed time: 17

Start time: 237
sessionId: 7
Stop time: 256
Elapsed time: 19

Start time: 256
sessionId: 8
Stop time: 270
Elapsed time: 14

Start time: 270
sessionId: 9
Stop time: 284
Elapsed time: 14

Start time: 1629
sessionId: 103
Stop time: 1643
Elapsed time: 14

Start time: 1644
sessionId: 104
Stop time: 1658
Elapsed time: 14

What I suspect is that the code these folks are using is very poorly written.  Potentially executing a Refresh() call for each session that is constructed.  If you are running into a performance problem with your AIF or Business Connector code feel free to contact me to help you track it down.  My consulting rates are reasonable 🙂

The code:

In order to thwart any comments that I cheated by placing my loop inside a using statement, I looped outside of it as well and the results are the same.