XAML Compile Error

Error    1    The "CompileXaml" task failed unexpectedly.
System.IO.FileLoadException: Could not load file or assembly 'X' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
File name: 'X' ---> System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.

If this happens, your operating system may have blocked the file. To unblock it follow these steps:

1. Find the .dll

2. Open properties and click on Unblock

image

3. Done :-)

Tip: Use the same resource (resx) file on both server and client

If you want to use the exact same resource file in two projects (for example client/server) you can create the resource in either of the projects and link it in.

image

To link a resource simply right click on the folder or project where you want the linked file and click:

“Add->Existing Item…”

In the file dialog select the item you want to link and click on “Add As Link”

image

Silverlight Quick Tip: INotifyPropertyChanged for indexer

Nice little tip by Pete Brown on 10rem.net

TextMate Vibrant Ink Theme in Visual Studio

Inspired by a meeting with Fredrik Normen, I decided to dig in and search for some cool theme for Visual Studio. I remembered a nice one I’ve used in TextMate, and so the google quest began…

The X marks the spot:

Vibrant Ink theme for VS by Rob Conery

XAML binding to local property in code-behind

I couldn’t find any good way to bind to a code-behind property after DataContext was changed.

After some digging I finally stumbled on this little neat trick:

Set the name of your root using x:Name and you can then access it trough ElementName.

Example:




Enjoy!

FormBorderStyle None for MDI child

An MDI child with FormBorderStyle set to None will still draw borders briefly when loading.
A microsoft report on this bug: connect.microsoft.com

If you do your own skinning this creates a very unprofessional look.

I solved it by overloading WndProc and handling WM_NCACTIVATE, WM_NCPAINT, WM_NCUAHDRAWCAPTION and WM_NCUAHDRAWFRAME manually.

I'll post some code later if someone is interested.

Mental note

http://www.pinvoke.net/

Remember to remember. I keep forgetting the link to this excellent site.