Visual Studio 11: Colorized Chrome

Allowing for the use of color within content to take center stage is increasing in importance as developers target Metro style clients such as Xbox, Windows Phone 7, and Windows 8. In targeting these platforms developers are creating user experiences that involve the use of bolder and more vibrant colors. These color palettes showcase much more effectively in a more monochromatic tool setting.

In VS 11 we have eliminated the use of color within tools except in cases where color is used for notification or status change purposes. Consequently, the UI within VS 11 now competes far less with the developer’s content. Additionally, notifications and status changes now draw user attention much more readily than before.

http://blogs.msdn.com/b/visualstudio/archive/2012/02/23/introducing-the-new-developer-experience.aspx

.net Event Validation, Dynamic Controls & ViewState

This has been an interesting week. I’ve been wrestling with the ViewState - here are my findings.

If you recieve the “Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation=”true”/> in configuration” the following tips might help you.

  • Don’t disable the enableEventValidation.  Event validation is good security feature of the framework, embrace it.
  • Learn how to set-up your Visual Studio to debug the .net framework code (see urls below for help).
  • If you are debugging through IIS then it’s quite likely you won’t be able to expose local variables when stepping through the framework - this was one of the many hurdles I had to overcome when trying to find out why the error was occurring - use the built in development server instead.
  • Disable the JIT compiler (see url below) to stop the optimisation of variables when ‘watching’ and viewing the framework variables.

Basically, you need to enable all errors so your project will break on the event validation error - this will usually be around the LoadViewState or Validation methods of the Control object.

Once you break on that error, check the call stack to find the point where the control causing the problem is trying to load or manipulate the viewState - with local variables up and display you should be able to get the id.

Once you know what control is causing the error, you need to ask yourself a couple of questions…

  1. Am I loading any controls dynamically?
  2. If you answered ‘Yes’ to question 1, then ask yourself if that control exists IN EXACTLY THE SAME PLACE IN THE CONTROL TREE when the page was first loaded.
  3. Have I added any new items to a control from the client that didn’t exist when the page was previously loaded?

In a case I found today, it seems that if you are loading controls dynamically, you need to add them back to the control collection when restoring the page from ViewState - what I didn’t know is that they needed to be in the right order…

I could be wrong, but .net seems to use the indexing when restoring ViewState - an example will make this clearer:

Controls[n].LoadViewState(state[n])
(ignore the syntax)


I was storing the dynamic control references in a Hashtable - which of course doesn’t maintain its order - and when I was loading the controls back, Control[n] was loading a incorrect piece of the ViewState for that control.  This will also clear up some of the:

Cannot cast T to T

ViewState errors you might see - the control is being fed the wrong values.

Setting up:
http://blogs.msdn.com/b/sburke/archive/2008/01/16/configuring-visual-studio-to-debug-net-framework-source-code.aspx

Disable the JIT (to partially stop the optimisation warnings):
http://stackoverflow.com/questions/279582/switching-off-the-net-jit-compiler-optimisations

1 note

Visual Studio 2008 designer not rendering?

I had a problem when viewing a user control in designer mode to re-configure the object datasources - nothing appeared in ‘design’ mode.

Instead of using the ‘design’, ‘split’ & ‘source’ tabs I right clicked the file and selected ‘view designer’ everything seemed to spring back into life then.

Configuring Visual Studio to Debug .NET Framework Source Code

I’m glad they’ve done this, even if it’s to mimic patterns, it’s always helpful to check what’s going on behind the scenes.

http://blogs.msdn.com/b/sburke/archive/2008/01/16/configuring-visual-studio-to-debug-net-framework-source-code.aspx

1 note

Complete reusable UserControl library in .Net

Want a library of complete (including html rendering), re-usable user controls you can use across multiple projects? Read on…

I’ve recently worked on a project where the client wished to port an internal website (kiosk) to the web.

The project was built using lots of usercontrols (which was not ideal as this was the existing developers way to separate the business logic) and I wasn’t about to start copying these across the 2 projects.

I created an empty web site in the solution (not a web project) and copied across all the controls into the root.  After deleting the designer files as these aren’t used in a web site project, I published the site to a directory with the following options:

This would publish the site and all necessary dll’s to the specified folder.  Now, reference the web site assembly’s from the project you need them on and include a reference to them in the web.config:

<add tagPrefix=”uc” assembly=”Assembly.Name” namespace=”ASP”/>

Note: On inspection of the outputted dll in reflector an ASP namespace is created and this is the namespace you’ll need to use to get your user controls.  Also, I haven’t found a way to keep the control name classes the same, you’ll see they are now something like ‘controlname_ascx’ and this is what you’ll be using in the code <uc:controlname_ascx runat=”server” />.

To make things more annoying, the resulting dll’s that are published are random and contain a hash of the directory in which the website lives - this is by design and used for conflicts.  I use ILMerge to compile the assemblies into a single assembly with a pre-defined name so I don’t have to keep changing the references.

Following

  • the-absolute-funniest-posts
  • funniest10k
  • evangotlib
  • mikelernerphotography
  • attentionindustry
  • tastefullyoffensive
  • infoneer-pulse
  • merlin
  • poplipps
  • cavalier
  • redshooter
  • frezned
  • amyvernon
  • minimalistco
  • theclearlydope
  • deviantart
  • yagottabelieve
  • mashable
  • poptech
  • gregbabula
  • john
  • teaim
  • despicablealexis
  • purple-lightsaber
  • toptumbles
  • hellonewyork
  • nonprofit-design
  • plus5mace
  • wantful
  • pixel2html
  • adobegripes
  • kimjongillookingatthings
  • tuneage
  • mikehudack
  • sirmitchell
  • officialbeastieboys
  • wondertonic
  • jordanwaller
  • badassjs
  • iiiil0liiii
  • fuzzythinking
  • manxmidge
  • rosskempfolds
  • londonelek
  • bigpinots
  • hoveringartdirectors