Blog Home  Home Feed your aggregator (RSS 2.0)  
.Net Jonesie - Visual Studio
A simple programmers blog
 
# Thursday, December 23, 2010

If you’ve been using VS 2010 for anything more than a few minutes you have probably had the clipboard issue – ie, copy and paste randomly breaks.  This is documented on MS connect here and probably elsewhere. 

The current recommendation is to install VS 2010 SP1 beta which I did this morning.

Unfortunately this doesn't work for me.  I still get random errors, albeit slightly different.  Now when I paste, the cursor moves back to what I had selected and nothing is pasted.

Happy days !

Thursday, December 23, 2010 1:29:41 PM (New Zealand Daylight Time, UTC+13:00)  #    Comments [1]   General | Visual Studio  | 
# Wednesday, April 21, 2010

I’ve been enjoying the stability and extra performance of a 64 bit OS for about 2 years now so I am surprise and somewhat disappointed that the latest round of goodness from Microsoft – i.e. SharePoint 2010, Office 2010 and Visual Studio 2010 have some annoying incompatibilities in this mode.


Datasheet View of  a SharePoint list with a 64 bit version of Office does not work, you just get this annoying dialog:

image

Apparently this is because the ActiveX control is not available for 64 bit OS’s.  I have only tested on 2008 R2 server – Windows 7 64 bit may be ok.

Also, Intellitrace in Visual Studio – aka Historical Debugging - does not support SharePoint (or any 64 bit app?).

I’m sure Microsoft are aware of these limitations and will offer solutions in due course – but really, 64 bit has been coming for a while and I think we can expect not to see this sort of incompatibility, especially for Office. 

For me this has tarnished my experience only a tad, but overall, 64 bit everywhere is better than 32 bit in the same way that cake is better than two week old bagels.

Wednesday, April 21, 2010 3:05:44 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]   General | Sharepoint | Visual Studio  | 
# Friday, April 03, 2009
I haven't used WIX a lot so I'm no expert, but I do know that is way better packaging solution than anything else that ships with Visual Studio currently.  Version 3 of WIX had progressed to the point that MS were helping to have it included in the VS 2010 out of the box.  Which is slightly ironic if you know the history of WIX.

However, it appears than plans and people have changed and WIX will NOT ship with VS2010.

This is very sad for us poor developers who are left with little out of box choices for solution packaging.  Sure you will still be able to get WIX yourself but many shops don't like to let developers help themselves to open source tools and are even meaner when it comes to paying for tools.  Inclusion of WIX with the VS2010 release would have moved WIX to the mainstream and finally put a nail in the coffin of VDPROJ packages.

For the full story, read here.

If you think this is a mistake then it may not be too late.  Microsoft always listen to customers.  If enough of us talk about this and express opinions then they may change their mind or at least offer WIX as a Power Tools or some such thing.

If you would like to have your say then either blog about this yourself or send an email to Soma (VP of Developer Division) via his blog: http://blogs.msdn.com/somasegar/contact.aspx

Friday, April 03, 2009 7:56:27 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [1]   General | Visual Studio  | 
# Monday, March 26, 2007

I’m a little late blogging about the MVP Summit – it finished on the 15th – but I’ve only arrived home yesterday.  The wife and I took the opportunity to do some tripping around – more on this later.

The Summit this year was great.  It was very well organized, the venue’s – Seattle’s Convention Center & Microsoft – were spacious and accessible.  Transportation was very easy and well organized this time.

As usual, we also got to here from some great & famous speakers, including: Bill Gates, Anders Hejlsberg & Scott Guthrie – all of which were highlights in one way or another.  We also got to learn about a few upcoming products and new releases – much of which I cannot repeat here – but here’s a few teasers.

  • Orcas – there are a lot of nice new features and enhancements in this – particularly around testing, Javascript, AJAX, design etc.  Debugging and development Javascript is a place I am very keen to see enhancements on and we saw some nice demos of improvements in these areas (including a fix for a long running complaint from many people).  I think the March CTP has some or all of these features included already so check it out.
  • ASP.Net v Next – Scott talked about and demo’d a few new features of the next version of ASP.Net in Orcas.  Again, I think this stuff is probably in the March CTP but without looking I’m not willing to risk the lawyers!  Lets just say that you will see more code-less provider model type things a some new controls that will save you a LOT of coding.
  • LINQ – Anders did a great demo of LINQ for Objects & SQL.  If you have been living in a cave and not heard of LINQ or have been ignoring it then RUN – don’t walk – to your nearest search engine and learn as much as you can about it now!  LINQ will change the way you work with objects and data in ways you may not have realized… eg PLINQ.
  • AJAX – Scott demoed some of the new Orcas features for AJAX.  He also detailed some features of the current release I was unaware of, including pageLoad().  There’s a great blog post here that shows how to use this and some other nifty features.
  • Team System – Rosario is the code name for VSTS after Orcas.  There’s not much public information on this so I can’t say anything but the very few tidbits I did here about it sounds intriguing. Use your imagination and look at some of the research and tools the team has been talking about and you will get a fair idea of where they are heading.
  • Lastly, some estimated delivery schedules were mentioned for Orcas & Longhorn… and I’m certainly not going to repeat those but it’s safe to say – I think – that by this time next year I’ll be blogging about Orcas SP1 :]
Monday, March 26, 2007 8:55:14 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]   General | Team System | Visual Studio  | 
# Wednesday, June 07, 2006

Rob Caron noted that Attrice have released a new free SideKick for MSBuild.  I have just downloaded and installed this.  If you are wanting to learn about MSBuild then this is a great way to get started.  The thing I really like about it is you can quickly view inherited targets, which for Team Build is great! 

For complex builds with many imports and custom tasks this is a great way to visualise and tidy your build projects.  It’s well worth the small download.

Wednesday, June 07, 2006 10:03:28 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]   General | Team System | Visual Studio  | 
# Saturday, April 29, 2006
Doh! DNN Template by peter@jonesie.net.nz
I've had several attempts at creating a new DotNetNuke web site on my local machine.  Thoughtfully, DNN 4 comes with a template project for doing this but for the life of me I couldn't find it when I created a new Web Project.  I spent hours trying to find a solution to what I thought was a broken Visual Studio installation and today I was going to re-install VS to fix the problem.
 
We'll this morning I had a brain wave (to make up fo the brain farts) and realised that DNN is a VB project so now when select Visual Basic in the new web site dialog I can see the DNN project template and it works.
 
Double Doh!  I seem to be able to think straighter lately.... a bit.
 
Saturday, April 29, 2006 8:42:45 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]   Visual Studio  | 
# Thursday, February 23, 2006
I just noticed that Visual Studio gives you a nice little tooltip in the Solution Explorer to tell you who has a file checked out (or not).
 
 
Is this new?  I normally don't keep the mouse stationary long enough to see tooltips.
Thursday, February 23, 2006 1:24:03 PM (New Zealand Daylight Time, UTC+13:00)  #    Comments [1]   Visual Studio  | 
# Wednesday, February 15, 2006
I'm jumping on the snippet bandwagon a bit late but this morning I realised I was repeating myself repeating myself repeating myself more than usual.  I am trying to figure out a bit of spaghetti I write a while ago that is getting events firing in the wrong order.  The logic is  bit too complex to step through so I'm adding tracing code and capturing this to a log file. 
 
Eg:
 

    1     private void fireModeChange()

    2     {

    3       Trace.WriteLine("Starting fireModeChange", "Designer");

    4       Trace.Indent();

    5       try

    6       {

    7         if (ModeChanged != null)

    8         {

    9           ModeChanged(this, new EventArgs());

   10         }

   11       }

   12       finally

   13       {

   14 

   15         Trace.Unindent();

   16         Trace.WriteLine("Ending fireModeChange", "Designer");

   17       }

   18     }

 
The time saving solution is to create a code snippet that surrounds the selected code with this block.  Creating a snippet is pretty easy when you've done it a few times, but to make things interesting I downloaded Snippy from GotDotNet.  It's a NLU (nice little utility) for creating snippet files.
 
 
Now surrounding the selected code is very easy.  Of course, it's taken me several hours of fracking about to get all this working and documented - but that's another blog post :}
Wednesday, February 15, 2006 12:01:20 PM (New Zealand Daylight Time, UTC+13:00)  #    Comments [0]   Visual Studio  | 
# Thursday, February 09, 2006
I've been looking at some complex code that someone else wrote lately and trying to figure out how it all works (or doesn't actually).  I've been adding lots of Trace statements so I can more easily follow the flow of execution.
 
Now, I'm not sure if this is a problem for anyone else or just my addled brain but I found that Trace statements in my Web Service don't display in the Visual Studio Output window unless I step into the Web Service code from the WinForms client.  This is a real drag.  All I want to do is execute the application and later examine the process steps.
 
A simple workaround is to use the TextWriterTraceListener.  With this I can capture Trace output to a file and look at the results after execute.  You do this by adding the following section to your web.config:
 
<system.diagnostics>
 <
trace autoflush="true" indentsize="2"
>
  <
listeners
>
   <
add name="myListener"  type="System.Diagnostics.TextWriterTraceListener" initializeData="mywebapp.log"
/>
  </
listeners
>
 </
trace
>
</
system.diagnostics>
 
 
However, I also rediscovered that by default, Trace messages also get output via OutputDebugStr() and this can be viewed with a suitable Debug Viewer.  Eg:
 
 
This DebugView is free from SysInternals.com.  It captures Trace messages from .Net apps and any other apps that use OutputDebugStr(), which includes Windows.  There is one problem that I noticed immediately though.  Trace.Write() appears like Trace.WriteLine() so you may loose some of the nice formatting that you would get in a log file but I can live with this.
Thursday, February 09, 2006 9:19:04 AM (New Zealand Daylight Time, UTC+13:00)  #    Comments [0]   General | Visual Studio  | 
# Friday, December 09, 2005
I've been playing with Testing in Team System this week (Wow!  I want to be a tester!  But that's another story for a later date).  I am creating a sequence of manual tests for UAT (we don't have any UI Testing tools) and I want the testers/users to start with a clean build of the system and database with each test run. 
 
Using RedGate SQL Packager I created a script to create the database with some sample starting data. I added a couple of tasks to my Team Build to create a database and execute the script on it.  Using my custom ExecuteSQL task I added the following:

<TestDBServer>fred</TestDBServer>
<
TestDBName>$(BuildNumber)</TestDBName
>
<
TestDBCreateConnectionString>
 data source=$(TestDBServer);integrated security=SSPI;Pooling=true
</TestDBCreateConnectionString>

<Message Text="Creating test database " Importance="normal"/>
<
ExecuteSQL ConnectionString="$(TestDBCreateConnectionString)"
   
Command="create database [$(BuildNumber)]" />

This created an empty database with a name of whatever the BuildNumber is.  Note the [ and ] around the $(BuildNumber). 

Next, I execute the script to create the database objects and populate it with sample data:

<Exec Command="isql.exe -E -S $(TestDBServer) -i $(BuildDirectoryPath)\SUMS3\SUMS3Debug\Sources\Airways.SUMS3\CreateTestDB.SQL -d [$(BuildNumber)]" />

The SQL script is checked in with the solution files, hence the funcky path to it.  I could have had it in the Team Build project folder, but it's more visible in the solution.

So, now my Team Build produces completely isolated instances.  Users can happily compare old versions with the latest and greatest version. 

Friday, December 09, 2005 4:28:39 PM (New Zealand Daylight Time, UTC+13:00)  #    Comments [0]   Team System | Visual Studio  | 
# Thursday, December 01, 2005
There's a bug in Crystal for Visual Studio 2005 (surprise surprise!) when you have a stored procedure in your report WITH parameters AND you change the database connection at runtime.  Basically, no matter what you do, it will tell you that the parameter has not been specified, when you know darn well that it has!
 
I found a discussion and the solution hereWish I was using SQL Reporting :{
Thursday, December 01, 2005 11:45:12 AM (New Zealand Daylight Time, UTC+13:00)  #    Comments [2]   General | Visual Studio  | 
# Thursday, November 24, 2005
I think this is a new feature, please tell me if it's not so I can kick myself.
 
When an exception occurs deep in some code, the reason is most likely at a much higher level, e.g.:
 
This exception occurred in DataSet code due to something wacky in the UI.  The call stack shows how we got here:
 
It's very easy to navigate back through the call stack and examine variable values etc, but often you have to restart the app with a break point set in a suitable place - at least that's what I thought till I noticed this:
 
 
When you select this it unwinds the execution of your application back to the selected Frame in the call stack.  How cool is that ?  Very cool I think.
Thursday, November 24, 2005 3:27:03 PM (New Zealand Daylight Time, UTC+13:00)  #    Comments [0]   Visual Studio  | 
# Tuesday, November 15, 2005
A friend and fellow Kiwi .Netter, Brent Clark, is repeating his popular web cast tommorow.  If you want to know more than your mother ever told you about building VB6 & VB.Net applications with lots of COM & VSSS then Brent is THE MAN!  Go Brent!
 
From a Microsoft .NET Framework build perspective, consuming evolving Component Object Models (COM) is not a trivial matter. This webcast describes how SunGard in Christchurch, New Zealand has extended its automated build processes to be able to interact with NET and COM components. Learn how SunGard was able to compile .NET solutions from Microsoft Visual Source Safe with strong naming, version stamping, and copyright stamping. You will also learn how SunGard automatically produced interoperability files for the ever-changing COM components. This webcast also describes how SunGard produced publisher policy files that allow the company to patch the minimum number of files in a client installation.
 
Presenter: Brent Clark, Build Process Architect, SunGard
 
Brent Clark manages the build process for a large 10-year-old system produced and maintained by SunGard in Christchurch, New Zealand. This system is made up of approximately three million lines of code  that are written mostly in Microsoft Visual Basic 6.0 but now extend into Microsoft Visual Basic .NET. Brent's responsibilities have included the automated analysis and compilation of Visual Basic 6.0 and .NET projects. He has also worked on deployment to internal clients and also branching and reintegrating separate subproject environments.

This can be found under http://go.microsoft.com/?linkid=4078252

 

Tuesday, November 15, 2005 2:37:25 PM (New Zealand Daylight Time, UTC+13:00)  #    Comments [0]   General | Visual Studio  | 
Microsoft and INeta are doing a big push with the launch of Visual Studio, SQL Server and BizTalk.  They have sent us some goodies and training materials so Tim and I have decided to run a series of BYO PC Workshops. 
 
This is a great way to learn the technology in a quiet, interruption free environment.  We will give a brief overview the subject and then you get to spend 1 to 2 hours working on exercises.  You get to do this on your own machine so you can take the materials away with you and play later. 
 
We will also be giving away a copy of Visual Studio 2005 Standard and SQL Server 2005 Standard at each of the workshops to one lucky attendee.
 
We decided to run the workshops in the early morning (8am) so as to minimise the impact on your working day.  If this does not suite enough people or there is sufficient demand for a different time we can probably re-run the events at a more civilised time.
 
Workshop details and registration can be viewed on the NZ .Net Site home page.
 
Tuesday, November 15, 2005 10:12:16 AM (New Zealand Daylight Time, UTC+13:00)  #    Comments [0]   Visual Studio  | 
# Thursday, November 10, 2005
Sadly, I'm finding a few issues with Visual Studio 2005 and Team System. 
  • The ToolStrip designer is less than stable.  If a ToolStrip overflows to the drop down menu you can add new ToolStrip items but you cant move them or delete them.
  • The WebDev.WebServer STILL drops connections which makes it useless for debugging.  I logged this as a bug a while ago.  I also managed to speak to the chap in Redmond who wrote this (or is at least responsible for it) while I was there for the summit.  Sorry, can't remember his name now, but he knew nothing of the issue then.  It may be just an issue on our systems (I've seen it on 2 machines) or with our project.  Has anyone else seen this problem?
  • Visual Studio locks up frequently.  Actually, it's not dead, just not responding.  The Task Manager shows about 50% cpu activity on devenv.exe but I have to kill the process.  I'm not sure but I suspect this might be a Team System Source Control issue.
  • Help is very slow to load.
  • Visual Studio can be very slow to load.
  • I had an issue with a solution yestuday that wouldn't let me open the projects in it or re-add them.  I had to create a new SLN and add the projects back in.  I think Team System Source Control is/was caching an incorrect path so even though I had a proejct file in C:\SomePath and I selected the project to add, it would look in a different path (where the project once was). 
All of these things are a little annoying but certainly not show stoppers.  I'll research these a little more and then log bugs for whatever I can nail down.
 
Thursday, November 10, 2005 11:44:54 AM (New Zealand Daylight Time, UTC+13:00)  #    Comments [0]   Team System | Visual Studio  | 
# Wednesday, November 02, 2005
Class designer won't load in Visual Studio
Wednesday, November 02, 2005 1:15:33 PM (New Zealand Daylight Time, UTC+13:00)  #    Comments [4]   Visual Studio  | 
# Friday, October 28, 2005
VS05 & SQL 05 RTM - Go get it! by peter@jonesie.net.nz
If your an MSDN Subscriber you can now download Visual Studio 2005 and SQL Server 2005 RTM.
 
Expect a looooonnnnnnngggggg download!
Friday, October 28, 2005 6:42:41 AM (New Zealand Daylight Time, UTC+13:00)  #    Comments [0]   Visual Studio  | 
# Thursday, September 01, 2005
I have a large dataset that is exposed to the client via a web service.  At the server end I have extended the dataset to include methods that fill it via TableAdapters, e.g:
 
namespace MyWebService.MyDataSet {
    public partial class MyDataSet : DataSet {
 
        public void FillEmployees() {
            EmployeeTableAdapter eta = new EmployeeTableAdapter();
                    eta.Fill(this.Employee);
            }
    }
}
 
On the client side I have extended the proxy version of the dataset to add methods to rows and tables to manipulated data contained therein.
 
namespace MyProxy.MyDataSet {
    public partial class MyDataSet : DataSet {
 
        public List<MyDataSet.SomeRow> GetListOfEmployeesByName(string name) {
        // blah
      }
    }
}
 
I have a few methods that I need at the client and server end.  It would be nice to have this code in a shared library and just wrap this in the dataset partial class, e.g:
 
// ws version
using MyDataSet.Shared;
namespace MyWebService.MyDataSet {
    public partial class MyDataSet : DataSet {
 
      public List<MyDataSet.SomeRow> GetListOfEmployeesByName(string name) {
          MyDataSetHelper helper = new MyDataSetHelper();
          return helper.GetListOfEmployeesByName(this, name); 
      }
    }
}
 
// proxy version
using MyDataSet.Shared;
namespace MyProxy.MyDataSet {
    public partial class MyDataSet : DataSet {
 
            public List<MyDataSet.SomeRow> GetListOfEmployeesByName(string name) {
          MyDataSetHelper helper = new MyDataSetHelper();
          return helper.GetListOfEmployeesByName(this, name);     
      }
        }
}
 
// shared code
namespace MyDataSet.Shared {
    public class MyDataSetHelper {
            public List<MyDataSet.SomeRow> GetListOfEmployeesByName(MyDataSet ds, string name) {
          // blah
      }
  }
}
 
 
But this wont work because of the the different name spaces.  What I really need it a generic helper:
 
 
// shared code
namespace MyDataSet.Shared {
    public class MyDataSetHelper {
            public List<R> GetListOfEmployeesByName<T,R>(T ds, string name) {
          // blah
      }
  }
}
 
And I use this in the proxy and server code thus:
 
 
// ws version
using MyDataSet.Shared;
namespace MyWebService.MyDataSet {
    public partial class MyDataSet : DataSet {
 
      public List<MyDataSet.SomeRow> GetListOfEmployeesByName(string name) {
          MyDataSetHelper helper = new MyDataSetHelper();
          return MyDataSetHelper.GetListOfEmployeesByName<MyDataSet, MyDataSet.SomeRow>(this, name);     
      }
    }
}
 
// proxy version
using MyDataSet.Shared;
namespace MyProxy.MyDataSet {
    public partial class MyDataSet : DataSet {
 
            public List<MyDataSet.SomeRow> GetListOfEmployeesByName(string name) {
          return MyDataSetHelper.GetListOfEmployeesByName<MyDataSet, MyDataSet.SomeRow>(this, name);     
      }
        }
}
 
In some simple scenarios this might actually work, but if MyDataSetHelper.GetListOfEmployeesByName() needs to manipulate MyDataSet properties then I need to have a constraint on the generic so it knows what members it has, e.g:
 
namespace MyDataSet.Shared {
    public class MyDataSetHelper {
            public List<R> GetListOfEmployeesByName<T,R>(T ds, string name) where T : MyDataSet {
          // blah
      }
  }
}
 
But then we are screwed again because MyDataSet is in 2 different namespace and you can only have a constraint on a single base class.  I could however set the constraint on DataSet, e.g:
 
namespace MyDataSet.Shared {
    public class MyDataSetHelper {
            public List<R> GetListOfEmployeesByName<T,R>(T ds, string name) where T : DataSet {
          // blah
      }
  }
}
 
And then I'd have to use untyped methods on the dataset within the helper method and I wouldn't be able to use typed methods.
 
So, basically, the only solution is to include all the methods on the server dataset and create my own proxy to used a shared library where this is implemented.
 
Or maybe you have another solution?  Or maybe I've just confused you more than I confused myself?

 

Thursday, September 01, 2005 3:26:19 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [1]   General | Visual Studio  | 
I found and logged a bug with the new WebDev.WebServer (Cassini) in VS05.  I even inlcuded a simple repro for the issue.  However, it looks like MS have shut up shop for fixing new issues and I guess this is not as important as other things - like shipping.  I should have logged it earlier.
 
Basically the problem is that it stops responding after 30 seconds of inactivity. Has anyone else got the same issue and found a workaround - other than switching back to IIS?

 

Thursday, September 01, 2005 10:02:18 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]   Visual Studio  | 
# Wednesday, August 24, 2005

I'm using the new ToolStrip and ToolStripContainer in our VS05 application and it looks hot!  However, I've had a lot of trouble getting the toolstips to behave and stay where I want them in design mode.

This morning I discovered that using the Document Outline works really well for moving stuff around on your winforms.  Now it all looks sweet.

Wednesday, August 24, 2005 8:34:02 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [3]   Visual Studio  | 
# Friday, August 12, 2005
A word of warning.  In VS 05, if you REMOVE a project from a solution, it actually get's deleted from disk and Team System Source Control.  Thank [insert your devine being here] for Undo Pending Changes!
Friday, August 12, 2005 8:51:33 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]   Team System | Visual Studio  | 
# Friday, August 05, 2005

This is one of those Friday afternoon problems.

In my 2005 Winforms client I have a nice fancy splash screen that displays the current version - 3.0.0.0 (yes, this is the 3rd version but the 1st .Net version) - which it retrieves from Application.ProductVersion.  Under the covers, ProductVersion is actually just AssemblyFileVersion from assemblyinfo.vb/cs.

Now, I wanted to have this auto increment the build number.  In VS03, you do something like this: [assembly: AssemblyFileVersion("3.0.0.*")] and the asterix is replaced with the next version on each build.  Well this didn't work.  All I got was "Version 3.0.0.*" in the splash screen.

Ok, fair enough, probably a beta issue or there is another way of doing it I'm not aware of.

HOWEVER, when I tried to exit the app, it crashed trying to save Properties.Settings.Default.  It said there was an invalid character in the file path.  Of course, there was an hour between these two issues so it took me a few minutes but eventually I figured that the version number is used in the settings file name.  Removing the asterix solved this problem.

FYI

Friday, August 05, 2005 4:08:43 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [1]   General | Visual Studio  | 
# Wednesday, August 03, 2005

I don't want to burst anyones bubble here, but I think there's a lot of people under the impression that SQL 05 & VS 05 are going to be released on November 7th.  From everything I've seen announced, this is the LAUNCH date, not the RELEASE date - they could be quite seperate things.  At the very least, I wouldn't expect to see DVD's/CD's in your mail box before December. 

But then, I could be wrong... and it wouldn't be the first time.

Wednesday, August 03, 2005 9:04:29 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [2]   General | SQL | Visual Studio  | 
# Tuesday, August 02, 2005

I have a DataGridView where I allow users to type in cell values, but I only want upper case.  To do this, you need to capture the control as it's being created and assign a KeyPress handler.  E.g:

    private void MyGrid_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
    {
      if (e.Control is DataGridViewTextBoxEditingControl)
      {
        e.Control.KeyPress += new KeyPressEventHandler(Control_KeyPress);
      }
    }


    void Control_KeyPress(object sender, KeyPressEventArgs e)
    {
      e.KeyChar = e.KeyChar.ToString().ToUpper()[0];
    }

Of course, you can extend this further to do all sort of things, but if your requirements are complex then it's probably advisable to create your own custom column.

Tuesday, August 02, 2005 10:09:30 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [2]   Visual Studio  | 

I like IE7, it's clean and fast and seems pretty stable.  HOWEVER, Work Item Tracking in Visual Studio 2005 Team Suite does not like it.  It causes VS to crash.

Luckily it uninstalls nicely and restores IE 6 as it was, so no harm done.

Tuesday, August 02, 2005 9:37:18 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [1]   General | Team System | Visual Studio  | 
# Monday, August 01, 2005

Last week I had a small disaster with the source control in Team System.  I managed to overwrite 3 files and lost about 2 weeks work.  The files has not been checked in correctly since mid June.  This was not a nice thing to happen :{

For some reason known only to - pick your God here - I mucked around with the file attributes on these files and then did a "Get Latest", which of course, overwrote the local versions with the old server versions.  Yes, that was a stupid thing to do!  However, I still haven't a clue why the files where not getting checked in correctly.  It may have something to do with the readonly file attributes being out of sync or something else.

So, a word of warning, don't get too comfortable with the Source Control yet - IT'S A BETA !!!  Go and check now that all your files are being checked in correctly and before doing a Get Latest, backup your local versions.

Roll on beta 3...

Monday, August 01, 2005 8:45:45 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [1]   Team System | Visual Studio  | 
# Tuesday, July 19, 2005

I'm not the most efficient coder.  Things like Resharper are a waste of time for me.  I prefer to repeat myself 4 million times rather than learn 23,000 keyboard shortcuts.  I think it's something to do with creative flow.

However, sometime you see things that are so easy and quick to use that you just adopt them without thinking.  Snippets are one of these.  David reminded me of this.

So, here's a custom snippet I created for inserting properties. This is pretty much the same as the default prop snippet, but I've added summary comments and I like my member vars to have a leading underscore:

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
 <CodeSnippet Format="1.0.0">
  <Header>
   <Title>jprop</Title>
   <Shortcut>jprop</Shortcut>
   <Description>Code snippet for property and backing field</Description>
   <Author>Peter G Jones (modified version of prop from Microsoft Corporation)</Author>
   <SnippetTypes>
    <SnippetType>Expansion</SnippetType>
   </SnippetTypes>
  </Header>
  <Snippet>
   <Declarations>
    <Literal>
     <ID>type</ID>
     <ToolTip>Property type</ToolTip>
     <Default>int</Default>
    </Literal>
    <Literal>
     <ID>property</ID>
     <ToolTip>Property name</ToolTip>
     <Default>MyProperty</Default>
    </Literal>
    <Literal>
     <ID>field</ID>
     <ToolTip>The variable backing this property</ToolTip>
     <Default>_myVar</Default>
    </Literal>
   </Declarations>
   <Code Language="csharp">
        <![CDATA[/// <summary>
  /// Backing variable for property $property$
  /// </summary>     
  private $type$ $field$;
  /// <summary>
  /// Property $property$
  /// </summary>
 public $type$ $property$
 {
  get { return $field$;}
  set { $field$ = value;}
 }
 $end$]]>
   </Code>
  </Snippet>
 </CodeSnippet>
</CodeSnippets>

I can see that creating more elaborate snippets is pretty easy.  I wonder if it would be possible to have CodeSmith snippets?  That would be really cool!

Tuesday, July 19, 2005 7:23:45 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [1]   Visual Studio  | 
# Monday, July 04, 2005

I'm trying to format contents of a cell in a DataGridView using the following code:

private void RosterGrid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
  ShiftCell sc = e.Value as ShiftCell;
  if (sc != null && sc.RosteredShiftRow != null)
  {
   if (!sc.RosteredShiftRow.ShiftRow.IsForegroundColorNull())
     e.CellStyle.ForeColor = Color.FromArgb(sc.RosteredShiftRow.ShiftRow.ForegroundColor);
   if (!sc.RosteredShiftRow.ShiftRow.IsBackGroundColorNull())
     e.CellStyle.BackColor = Color.FromArgb(sc.RosteredShiftRow.ShiftRow.BackGroundColor);
   e.Value = sc.ToString();
   //e.FormattingApplied = true; // tried this and it make no diff
  }
}

This should set the current cell colours for some cells only.

However the result is crap:

Anyone got any ideas?

Update:  I fixed this by making sure I set the background colour to something valid.  Sometimes is was being set to 0 and other times it was not being set at all.  Now I either set both colours or none and it works really well. 

Monday, July 04, 2005 12:20:14 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [1]   General | Visual Studio  | 
# Thursday, June 16, 2005

Rob Caron has posted that the June CTP of Team System is available for download.

I've got too much on at present to bother with this and we were also asked not to upgrade or patch past Beta 2 as part of some programs we are on with Microsoft.

I'd really like a new cut of Visual Studio though.  Some of the bugs drive me nuts.

Thursday, June 16, 2005 1:06:47 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]   Team System | Visual Studio  | 

Wow!  My boss found this yesturday - I think it's a new feature in VS05 because I've never seen it before.  I'll be really annoyed if it's been in VS03 and I just never found it.

When you create a winform user control you normally need some container to test it in.  In the past I've always just done this as part of the larger application.  Now, when you have a control library project in VS, you can hit F5 and it will launch the UserControl Test Container:

Even better, you can load froms from any dll or exe:

Very cool!  This is a lot like the old ActiveX test container - but way nicer to use.

Thursday, June 16, 2005 9:16:21 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [1]   Visual Studio  | 
# Friday, June 10, 2005
How to retrieve multiple results sets from a stored procedure into a dataset with a DataAdapter.
Friday, June 10, 2005 9:48:07 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]   SQL | Visual Studio  | 
# Monday, May 30, 2005

I've been coding steadily for a couple of months now so I thought it was time for a few more favorites of VS05.

Refactoring
I tend to not use fancy tools like Resharper as I like a nice clean environment, even at the risk of getting OOS/RSI/CTS.  However, I find myself using the refactoring tool in VS 05 a lot more than I thought I would.  I particularly like the automatic method stubs it creates for you.  Also having it insert the namespace is very useful.  Both of these mean you don't lose your place in the code and can just continue on with the same train of thought.  I get easily distracted so this is a big boost for my productivity.  Things like rename, parameter delete, extract method are less useful at this point, but are more important features to have automated.

Snap Lines
I do a lot of win forms ui development - a lot more than I care to mention.  With snap lines, you can line up your controls horizontally and vertically in a simple visual way.  Very cool!  Don;t know why someone didn't think of this years ago.

Intellisence
Intellisence seems to be a lot more intelligent in VS05.  I can often enter several lines of code with very little typing.  When you type '.' the list of methods and properties is often positioned on the right item.  I think I type about 1/3 less than I do with VS03.

Source Control
The new team system source control is very fast and as far as I can tell, very secure and reliable.  The integration with VS is seamless and I'm not having nearly as many issues as I used to with VSS - it's seems a lot easier to create a source structure that matches your repository structure.  I haven't had the chance to use Shelving in anger yet, but I'm, sure it will be very useful when I need it.

The integration of work items into the checkin process is also very useful but I do find it awkward finding the correct work items in the list.  This is probably because of the way I work - which I think needs to change.

Data Sources & Data Binding
I know a lot of people hate data binding and it's a bit if a dirty subject, but I'm not afraid to confess that I use it.  I must admit though that it's not without it's problems at times.  Most of the issues I have had in the past (and some in the very recent past!) are due to a poor implementation in the tools or lack of understanding of how it works.

I think MS have got it right this time.  Setting up a data binding to a control is simply a matter of dragging a table or field from the data source window onto your form.  You can also bind to an existing control by dragging a field onto it.  You still need to write some code to attach the binding source to the actual data, but this is trivial.

If you don't like using data binding then just using the data source window to add controls to your forms will save you a lot of time.  Once you've dragged on your fields, just remove the binding source from the form and all the data binding will be removed with it.

Nullable types
I didn't think I'd use nullable types much, but it turns out I do.  I have created stored proc's that take int's and datetime values as parameters.  When I add a table to a dataset and specify the stored procs to use, VS05 automatically creates Fill & Get methods that have these parameters as nullable types.  Eg, the following stored proc:

   procedure GetEmployees
    @validdate datetime
   as
    select e.*
    from employee e
    where isnull(@valid_date, e.startdate) between e.startdate and e.enddate

VS05 will create an employeeTableAdapter with a Fill method thus:

   Fill(EmployeeDataSet ds, DateTime? validdate);

So I can call Fill(ds, DateTime.Now) to get all current employees or Fill(ds, null) to get all past and current employees.  No more need for DBNull!

Partial Classes
Partial classes make a lot of sence for win forms.  All of the designer generated code is in a separate file, making code changes a lot cleaner (and safer?).  However, I noticed that if you have an inherited form, you don't get a partial class - all the controls are included in the one form.

Monday, May 30, 2005 10:12:27 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]   Visual Studio  | 
# Thursday, May 26, 2005

I normally wouldn't post about bugs in beta products (it's a beta after all) but this one is so annoying I thought people might like to know what I did to work around it.

Pre-beta 2 I noticed a rather annoying problem in Visual Studio 05 - some keys stop working.  Usually this is backspace, delete, undo, escape etc.  Everything but alpha keys.  It was very annoying!

So, I was a good chap and logged this on the product feedback site.  MS have recently responded and said that it will be fixed in a forthcoming CTP.  In the meantime,  I've been getting this a LOT recently and I was having to either restart VS.Net or reset the window layout - often 5 - 10 times a day.

The bug is caused by the tool windows (solution explorer etc).  You can usually get it to fault by pinning and un-pinning the solution explorer or properties window.

I found a better workaround.  Simply undock all the tool windows that live on the sides of VS and move these to your 2nd monitor.  Everyone has a second monitor right?  Well, if not, then you may not have room.  Since doing this a couple of days ago I have not had the problem.

Thursday, May 26, 2005 9:15:01 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]   Visual Studio  | 
Copyright © 2012 Peter G Jones. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: