While reading my usual list of blogs I came across an article on nothingbutsharepoint by Waldek Mastykarz on SharePoint Scenario Framework. This is something I have never heard of before but after reading the article I can definitely see the use of it so wanted to spread the word.
During my time I have created and consumed numerous web services. There are quite a few good guides out there such this MSDN article but the one thing I always forget is where to run the disco tool from to generate the WSDL and Disco aspx pages.
The funny thing is there is a few different places you can find this tool they are:
- In the Microsoft SDKs folder in Program files, usually in the bin folder. At the time of writing this I am using Windows Server 2008 and there are two options either v6.0A or V7.0A and in my case disco.exe is in the bin folder of V7.0A.
- This can also be accomplished using the Visual Studio command prompt. Simply open it and type disco and you will be asked for the appropriate options.
- I have also found on some servers there is also a copy at C:\windows\Microsoft .NET\Framework\Verisonx.x.x.x\ although this is not always the case. This could have been added when additional software has already been installed.
Regardless of how often I have done this I still always forget so hopefully this will help me remember but also help anyone else who is also as forgetful as me
Over the years I have created numerous Windows Forms Applications for a variety of purposes. Normally this is for my own use or for use by an IT team but on a recent project I was developing a Windows Forms Application which is to be used by regular Joe Blogs end users. This meant I needed to provide an installer to ensure all the prerequisites were installed i.e. .Net framework, etc. While it is not something I have had to do a lot of I have created a few installers in my time, however most of them have used the OOTB Setup Project template from Visual Studio.
On this project I am still using the OOTB Setup Project, however I have also had to capture some additional parameters during the installation such as the URL of the web service to connect to. I knew this would be possible but I had no idea what would be involved but after some research I was able to find an excellent MSDN article on Using a Custom Action to Display a Message at Installation. While the idea is slightly different the principle is the same and you can easily adjust this. In my case I capture the web service URL and update the settings file with the URL supplied. I found a good article which details the steps required to update the configuration file. My code is slightly different in that it is within the custom installer class so I have included this below as well.
Code in Customer Installer Class
When working on a Windows Forms Application I had a DataGridView and I wanted to update some textboxes at the bottom of the form when the user selected a particular row/cell. I looked at the different DataGridView events available and decided the best option to cover users clicking on a cell and them navigating around the DataGridView using the up and down arrows was the CellEnter event.
Everything seemed to be working fine but I was occasionally getting some strange result or errors so I decided to spend some time debugging to try and identify the issue. What I found was even if I was not clicking on the DataGridView certain other actions caused the CellEnter event to fire also when I first clicked on an a row/cell after loading the form the event fired twice. This was extremely problematic in my case as I was doing some additional processing on a background worker thread so these miscellaneous events being fired resulted in unexpected results and the occasion exception as the background worker thread was already in the middle of processing another request.
Reading up on the CellEnter event it mentions that the event may occur twice if the DataGridView didn’t have input focus. Thinking about it this made sense and related to the issue I was having where the event was indeed firing twice. What must be happening is when a user clicks on a cell the focus must first be set on the DataGridView and when this happens it must act like it is selecting the first cell hence every time I was debugging the first time around the column and row indexed were both 0. I was able to get around this by adding the code below to the top of the CellEnter event. This way if the DataGridView wasn’t Focused I could exist the event without processing.
This seemed to work but it meant when I loaded the DataGridView first time around the additional information at the bottom of my form was not filled in as technically the form still didn’t have input focus. I was able to get around this by manually setting the focus on the DataGridView after I assigned my data source. This would then trigger the CellEnter event where DgvData.Focused would now be true so it would continue and do the additional processing I wanted.
The other issue I was having was the CellEnter event was firing when I was not touching the DataGridView. In my form I had multiple tabs and the DataGridView was on the first one. I have several buttons on the form that show or hide the relevant tabs but what I noticed was that removing a tab from the TabControl also triggered the CellEnter event. The code below shows the function I was using to only show the appropriate tab and when stepping through the code line 11, actually removing the tab from the TabControl, caused the CellEnter event to fire. Obviously this was not what I was expecting and was leading to incorrect data on certain sections of the form. What I found was the same fixed I used above also corrected this issue as while the event still fired the DataGridView didn’t have input focus so it simply existed the method.
Hopefully this can help other people encountering the same issue as it took me a while to work out why this was happening and how to resolve it.