Posts

Showing posts from 2012

Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions.

If you're using ASP.NET MVC and are using the HTML helper DisplayFor or EditorFor to render a partial view and you, in runtime, get a nasty InvalidOperationException, saying ... Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions. ... it might be because you have been over-zealous and typed your Model object's property as an interface (say ICollection) instead of a concrete type (say List). Just sayin'.

Debugging Word-addins

Debugging addins always ends up being cumbersome. The best solution when developing addins, I have found, is to be very careful to ensure that your business logic is separated from the addin itself, so that you can load that very same business logic in a test harness whenever you need to add new features, or identify and correct bugs. However, if you are stuck with an existing solution, you can generally debug your addin by starting the hosting process - Word in this case - and then attach to that process (Debug - Attach to Process). Don't worry if you see seval Word processes running - you can attach to more than one by CTRL-clicking. Then, once you are attached, just set breakpoints in your code and execute the addin functionality to start debugging. It's not working! If you've followed the guide above and you're still not hitting any breakpoints, the code in your environment and the one deployed as your addin may not be in sync. To work around this issue, shut dow

My Metroapp is not showing images!

If you're working in code-behind, are trying to load an included BitmapImage and your app, although it loads, is not showing the image, it might be because you're not using the appropriate protocol. In the Windows 8 Consumer Preview, the correct protocol for loading included images is ms-appx: BitmapImage img = new BitmapImage(new Uri("ms-appx:///Images/my_image.png", UriKind.RelativeOrAbsolute)); In the above case, the image is set as Content (for C#-projects; Image  for C++ ones) and resides in the Images solution folder. For more information about loading images, please see Microsoft's official sample  App tiles and badges sample .

Programmatically show and hide the Windows taskbar

I've been working on an application launcher for multi-touch surfaces. As a part of the experience, I wanted to hide the Windows taskbar, as it didn't feel very 360 degrees - multi-touch - multi-user , as was the intention of my launcher. Anyway, this is what I compiled: WPF App Constructor         public App()         {             ViewModel = new AppViewModel();             _systemTrayHandle = FindWindow("Shell_traywnd", "");             _startButtonHandle = FindStartButton();         } Imports         #region Windows API Imports & Utilities         [DllImport("user32.dll", SetLastError = true)]         static extern IntPtr FindWindow(string lpClassName, string lpWindowName);         [DllImport("user32.dll")]         [return: MarshalAs(UnmanagedType.Bool)]         static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, SetWindowPosFlags uFlags);         [DllI

WCF Services, NotFound, WP7

Hi there, If your runtime environment claims that the server hosting your silverlight-enabled WCF service suddenly responds with a "NotFound" response, it might actually be lying. You can double-check this by using the Internet Explorer app on your phone to access just about any other resources on the web. If it cannot access microsoft.com either, it's time to restart your emulator.

One-liner to identify mobile apple (iOS) browsers

So, it struck us today, that Apple's mobile browsers does not support file uploads from web sites ( https://discussions.apple.com/thread/3043183?start=0&tstart=0 https://discussions.apple.com/thread/2714162?start=0&tstart=0 https://discussions.apple.com/thread/2659440?start=0&tstart=0 https://discussions.apple.com/thread/3095867?start=0&tstart=0 ). The reason for this, is that the user does not have access to the file system in iOS (no "My documents"), and inter-app communication is severely lacking. Anyway, if you are to design a web site to accommodate iOS users, you might want to hide your file upload control and/or show a friendly message to users using these devices. A one-liner that identifies such a browser is: Regex.IsMatch(Request != null && Request.UserAgent != null ? Request.UserAgent : "", "Mozilla\\/5.0 \\(iPod|iPad|iPhone.+?\\).*?Mobile"); The code snippets expects: That you have referenc

WP7 “The remote server returned an error: NotFound”

This might mean that you have not declared proper capabilities in your WMAppManifest.xml - to be able to access the network, you need to add the ID_CAP_NETWORKING capability.