Supressing CSS Errors in Visual Studio 2010

November 18th, 2010

While attempting to migrate some older, legacy ASP.Net pages from VS 2005 to VS 2010 I started getting the following errors:

Validation (CSS 2.1): 'set-focus' is not a known CSS property name.

These were fatal errors and were preventing me from making any further progress. Given that, at this point, I don’t really care if the HTML validates without errors I went looking for a way to prevent Visual Studio from producing these errors.  I finally found it in Tools | Options | Text Editor | CSS | Miscellaneous.  Simply uncheck the Detect Errors box.

Mixed Language Programming in ASP.Net

November 18th, 2010

For historical reasons I find myself developing some ASP.Net content in a mixed language environment.  I have some older, legacy code written in C# that I need to integrate into a new web site written using VB.Net.  Putting the VB.Net .ASPX pages into a separate directory from the C# .ASPX pages got around most of the problem, but I was left with some common code that belongs in the App_Code directory of both sites.  .Net won’t let you compile mixed languages into a single assembly, and since everything the the App_Code directory needs to be compiled into a single assembly I was in a bit of a quandary about what to do.

Fortunately, it turns out there is a simple solution to the problem.  You just need to put your C# code into a sub-directory of the App_Code directory and make an entry in the  <compilation> section of the web.config file. Add the following XML:

<compilation ... >
<add directoryName="App_Code_CS" />

Where App_Code_CS is the name of the sub-directory containing the C# code.

Forcing Data Entered into a WPF DataGrid to UpperCase

November 17th, 2010

All I wanted to do was force data entered directly into a DataGrid into upper case.  You would think this would be an easy thing to do.  Far from it.  It involved delving into things called ValueConverters, which are not that difficult to write but are a major pain in the butt to actually use.

Read the rest of this entry »

Adding Rows to a WPF DataGrid Programatically

November 17th, 2010

If you are going to let your users edit data in a DataGrid, at some point you will want to allow them to add records to the grid.  Adding a new row is simplicity itself, you just add a new item to the collection that is acting as your data source.  Suppose we are working with the data source from my prior DataGrid article.  We just add a new Account object to our Accounts collection, like this:

Accounts.Add(New Account())

This adds a new row to the DataGrid but it doesn’t put the grid into edit mode with the new row as the currently selected row.  Doing this is a bit more involved.  First we need to set the currently selected row by setting MyGrid.SelectedIndex to the index of the Account object in our collection.  For a newly added row, that would be Accounts.Count - 1. i.e. the last object in the collection.  Then we need to set the currently selected column by setting MyGrid.CurrentColumn to the first column in the row.  This will always be MyGrid.Columns(0).  Then we need to put the grid into edit mode by calling MyGrid.BeginEdit(), which puts the currently selected cell into edit mode.  Finally we need to give the grid focus by calling MyGrid.Focus().  The complete code to add a row and set the grid into edit mode looks like this:

' Add a new account to our list of accounts
Accounts.Add(New Account())
' Make the newly added account the current row of the grid
MyGrid.SelectedIndex = Accounts.Count - 1
' Make the ID field the current column of the grid
MyGrid.CurrentColumn = MyGrid.Columns(0)
' Put the grid into editing mode
' Give the grid control focus

It seems like nothing is ever easy with this stuff.  Sigh.

Binding Data to a WPF DataGrid

November 17th, 2010

Binding a data source to a WPF data grid is not exactly difficult, but it isn’t exactly easy or convenient either.  The only way that I have found to do it, so far, involves a combination of code behind logic and manually editing the XAML.  There are some short cut methods that can reduce the amount of XAML code that needs to be manually edited, but I find these short cut methods to be less than completely satisfactory.

Read the rest of this entry »

Developing .Net Applications on a Network Share

November 17th, 2010

If you keep all of your development projects on a network share like I do then you have probably had to deal with certain challenges regarding permissions along the way.  In the Win32 world this isn’t usually too bad, but in the .Net world it can become a major pain in the butt.

When you keep your project on a network share, all of the assemblies that your project references and all other assemblies required by your project a typically kept in the project’s bin directory.  Everything will seem to be just fine until you try to execute your application.  At this point you will start getting all kinds of strange errors when your applications tries to load dependent assemblies from the network share.  It turns out that .Net 4.0, by default, doesn’t allow assemblies to be loaded from a share.

Once you know the secret, fixing this is actually not that difficult.  You have to add a line to the app.config file for your project.   In the <runtime> section of the configuration file you need to add:<loadFromRemoteSources enabled=”true” />

That’s all there is to it.

Internet Explorer Tab Settings

November 10th, 2010

I don’t find the default behaviour used by Internet Explorer for handling web pages that open in new windows to be very convenient.  The newer versions of IE are tabbed browsers after all so why should new pages open in a new instance of IE rather than a new tab? Fortunately, it is easy to change the default behaviour.

  1. Start IE
  2. Click Tools | Internet Options
  3. Click the Settings button in the Tabs group
  4. Under When a pop-up is encountered select Always open pop-ups in a new tab
  5. If you want the newly opened tab to become visible automatically check the Always switch to new tabs when they are created

Developing ASP.Net Applications on a Network Share

November 9th, 2010

If you keep all of your development projects on a network share like I do then you have probably had to deal with certain challenges regarding permissions along the way.  In the Win32 world this isn’t usually too bad, but in the .Net world it can become a major pain in the butt.  This is especially true of ASP.Net applications.

I recently started work on my first ASP.Net application.  Everything was going fine until I tried to execute it.  Visual Studio’s internal web server basically told me to piss off.   It turns out that, by default, ASP.Net will not execute applications from a network share.

Once you know the secret, fixing this is actually not that difficult.  You have to add a line to the devenv.exe.config file for your version of Visual Studio.  For Visual Studio 2010 this is found in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE.    In the <runtime> section of the configuration file you need to add:

<loadFromRemoteSources enabled=”true” />

That’s all there is to it.

SecurityException While Accessing WCF Service

November 9th, 2010

I am just getting started with Silverlight.  For my first application, I wrote a simple form that interacts with a WCF service for database access.

The first time I tried to access the WCF service from the Silverlight application I got a SecurityException.  The error message that the exception gave was long and rambling and mentioned things like “cross domain access” and other fairly meaningless bafflegab.  I spent a lot of time Googling for solutions to this problem and the results all had to do with tweaking the IIS security settings, which are irrelevant when using Visual Studio’s internal web server.

Read the rest of this entry »

Internet Explorer “no such interface supported” Errors

October 21st, 2010

Lately I have been getting the infamous “error on page” message when attempting to access certain web sites using IE 32-bit on Windows 7 64-bit.  A little digging revealed that the actual error was “No such interface supported” errors being thrown by the Java script method.  Google reveals a number of suggestions for how to fix this problem, most of which involve registering various DLLs using regsvr32.  None of the suggested fixes worked for me though.

Finally I found that using IE 64-bit got rid of the problem.  Obviously there is a problem running IE 32-bit on 64-bit windows.  Sheesh!

Updated 11/10/2010

I finally got completely fed up with having to remember to run IE 64-bit for sites that used the method.  A bit more Googling turned up a link to a script that re-registered all of the DLLs required to make IE 32-bit happy.  The script can be found here:

There are number of files available for download.  To fix this problem you want the one titled

Just close all open applications on your PC and run the .CMD file.  To do that, extract the .CMD file from the ZIP archive, start CMD.EXE as administrator and execute the .CMD file.

You can also get the file  here.  This is just a copy of the file downloaded from the link given above.  I make no guarantees about the usefulness or safety of this file.  Use at your own risk.