Feed Subscribe
Exception has been thrown by the target of an invocation.


Modeling Power Toys for Visual Studio 2012

by ondrejsv 23. February 2013 17:38

AKA PowerToys for the Class Designer and Distributed System Designer is a set of useful extensions for the Visual Studio Class Designer delivered as two Visual Studio add-ins. Binaries for the Visual Studio 2010 can be found on the project home site together with sources. Unfortunately there is no version for the Visual Studio 2012 and getting sources compiled without errors for it is not a matter of simple CTRL+SHIFT+B.

So I did all heavy lifting for you and you can download binaries here.

DISCLAIMER: Please, remember that I am not author of the add-in, I take no responsibility for anything related to using it. I’m providing it as it is and all credits go to the original author lie.

In the zip file you find three assemblies and two XML files with AddIn extensions. Copy all files to any folder in which your Visual Studio looks for add-in, e.g. %APPDATA%\Microsoft\MSEnvShared\Addins (maybe you will have to create some of these folders). List of all folders where add-in files are being looked for is given in the Add-in Security in the VS Options:

image

Restart of Visual Studio is required. You can confirm loaded add-in in the Tools/Add-in Manager dialog:

image

then have fun with additional Class Designer commands:

image

Tags:

Getting rid of The current page has been customized warning in SharePoint 2010

by ondrejsv 26. December 2011 18:18

New WikiEditPage’s in SharePoint 2010 are great. Users finally may place web parts anywhere on the page and they don’t need any cumbersome ContentEditorWebPart’s with odd “Edit RTF” buttons.

There are times, however, when developers (or even power users from SPD) customize the page, to include some javascripts or other goodies. After customization of a WikiEditPage SharePoint shows a yellow warning (more precisely called status) in the display mode:

image

Not pretty. How to get rid of it? SharePoint supports an undocumented file property called “HidePageUnghostMessageV4”. Based on its name I suppose its sole purpose is to hide the message when the page is unghosted (i.e. customized). There seems to be a bug in the rendering code because when I set the property to “true”:

image

only the hyperlink for reverting disappears:

image

It’s possible that it’s not a bug but a feature but I would more appreciate if the flag worked by completely disabling the warning and not only the hyperlink.

The only way I know to turn off the warning now is to write a custom derived subclass of the SharePoint’s WikiEditPage that does not render the JavaScript for rendering the status warning (these messages are inserted in the status bar by calling the SP.UI.Status.addStatus JS function). WikiEditPage emits a little JavaScript code in the PreRender method by calling the well-known ScriptManager.RegisterStartupClientScriptBlock. Note that there is no way to unregister such a startup script. I mitigated this little complication by registering a startup script with the same key as WikiEditPage uses and with no body first, before the original PreRender code gets chance:

namespace Ondrejsv.CustomWikiEditPage { public class CustomWikiEditPage : WikiEditPage { protected override void OnPreRender(EventArgs e) { ScriptManager.RegisterStartupScript((Page)this, typeof(WikiEditPage), "unghostWarning", "", true); base.OnPreRender(e); } } }

The ordering of the statements is crucial here because if the base method call was first then the ScriptManager would emit the original script.

Don’t forget to place an entry into the SafeControl list, too. I created a Visual Studio solution for all of this and you may download it and deploy to your farm.

Now open your page in the SharePoint Designer and change the Inherits attribute in the Page directive from Microsoft.SharePoint.WebPartPages.WikiEditPage to Ondrejsv.CustomWikiEditPage.CustomWikIEditPage  (or whatever you call your custom class) and add a new Assembly directive for SharePoint to find the class (you may omit this directive if you place the full name in the Inherits attribute, of course):

image

No more the yellow pesky warning:

image

Note that any other warnings get displayed correctly:

image

Download the VS solution.

Tags:

On efficiency loss with JavaScript

by ondrejsv 15. September 2011 22:34

With the hype of Windows 8 HTML5/JS apps I’m again and again rediscovering some of the pitfalls of the JavaScript language which bring issues we never have with strongly-typed languages like C#.

The first scenario is going to be quite common not only when using the new promise/then feature. (Snippet is taken from one the tutorials on the MSDN.) Look at the processPosts function that gets called when the xhr promise gets asynchronously fulfilled. There is no way the IDE would know the type (more precisely available methods and fields) of the argument and thus providing IntelliSense because the function could be called from everywhere:

image

If we write the code to run when the promise is fulfilled as an anonymous function and Visual Studio would be way smarter, it could theoretically provide IntelliSense on the result argument by parsing and processing the xhr promise but it does not so:

image

The second pitfall comes from the fact that any code could be run in a context of any HTML file. When you reference a .js file from an HTML page, some of the global variables get alive by getting references of the screen elements with variables of the same id. If you make a typo in the name of a variable, you would not find it out until you run the page. Of course, there is no IntelliSense either because the variable could be of any dynamic type at run-time. This pitfall is really a feature of all dynamic languages but for a programmer used to program user interfaces in ASP.NET and Silverlight which have concepts of code-behind coded in strongly-typed C# it represents a loss in efficiency, indeed.

image

image

Tags:

Some observations on managed Windows 8 metro applications

by ondrejsv 15. September 2011 20:20

This is an unstructured list of interesting things I found when playing with the new metro applications.

While HTML5/JS metro applications always run in a host process WWAHost.exe (Windows Web Application Host?), .NET apps does not, they run directly in its own process:

image

image

When deployed locally from the Visual Studio, applications (both HTML5/JS and .NET) are stored within the folder AppxLayouts in the user folder. It is interesting that XAML and content files are not embedded as resources in the executable but they are left alone:

image

As the WinRT is native, every external event such as Click comes from the blackbox:

image

If we look at modules currently loaded when a managed application is running:

image

we’ll find some interesting things:

  • despite the fact that in a Metro app you may use only a subset of the full .NET, it looks like some of the full .NET modules are loaded (mscorlib.dll, System.Runtime.dll, System.Linq.dll, System.Core.dll, System.dll, System.Xml.dll and others), so a managed application obviously does not only forward calls to the native WinRT,
  • of course, a number of WinRT modules are loaded (with .winmd extensions)

.NET 4.5 assembly references are evident if we look at the application from the Reflector:

image

Tags:

List of Windows 8 Metro applications in DevPreview

by ondrejsv 14. September 2011 23:13

We all know that that there are two main approaches to develop new “Metro” style applications in Windows 8: HTML5/JavaScript and .NET (predominantly C# and VB.NET) and one complementary approach (C++/XAML). What technologies did Microsoft choose to write demo applications coming in the Developer Preview?

Here’s a short list containing all applications packed up in the Windows 8 Developer Preview together with technologies they are build on and other comments.

So what would be a management summary? 29 applications, 5 of which are written in .NET/XAML, 2 probably in C++/XAML and the rest are HTML5/JS.

Name Technology Comment Immersive tile
Alarms HTML5/JS   image
Piano (audiotagpiano) HTML5/JS   image
BitBox HTML5/JS sound loops sequencer image
BUILD HTML5/JS just a little app showing BUILD sessions image
Copper C++/XAML ??? simple 3D demo image
Five in row HTML5/JS   image
Flashcards HTML5/JS   image
News (hermes) HTML5/JS   image
Chess (checkm8) .NET/XAML   image
Ink Pad HTML5/JS   image
Labyrinth HTML5/JS   image
Measure It HTML5/JS   image
Memories .NET/XAML   image
Mopod HTML5/JS   image
Air Craft (myplane) HTML5/JS   image
Near Me HTML5/JS   image
Notespace HTML5/JS   image
PaintPlay HTML5/JS   image
Picture Stream (picstream) .NET/XAML    
Socialite HTML5/JS    
Stock HTML5/JS   image
Sudoku .NET/XAML includes Tim Heuer’s code image
Tile Puzzle HTML5/JS   image
Treehouse Stampede! HTML5/JS   image
Tube Rider C++/XAML ???   image
Tweet@rama HTML5/JS    
Weather HTML5/JS   image
Word Hunt HTML5/JS   image
Zero Gravity .NET/XAML Ported Windows Phone 7 application image

Tags: