Unable to run default XAML in Blend or VS2005

Scenario A:

I open VS2005, Under the Visual C# node I select Net Framework 3.0, and then select Windows Application (WPF) from the templates on the right.

The following code is generated:

<Window x:Class="WindowsApplication8.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WindowsApplication8" Height="300" Width="300"
>
<Grid>

</Grid>
</Window>

When I try to compile and run the app, I get the following error:

Cannot create instance of 'Window1' defined in assembly 'WindowsApplication8, Version=1.0.2613.23423, Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an invocation. Error in markup file 'Window1.xaml' Line 1 Position 9.


Scenario B:

I create a new (Standard Exe - Visual C#) project in Expression Blend (Beta 2). And the following XAML is created by default:

<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xml:lang="en-US"
x:Class="UntitledProject6.Window1"
x:Name="Window"
Title="Window1"
Width="640" Height="480">

<Grid x:Name="LayoutRoot"/>
</Window>

I hit F5 to build and run the app, and the following error is generated:

Cannot create instance of 'Window1' defined in assembly 'UntitledProject6, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an invocation. Error in markup file 'Window1.xaml' Line 2 Position 2.

What complicates things even further (for me, at least) is that all of the sample projects which comes with Expression Blend (Beta 2) build and run without problem.

Additionally, these XAML-blocks both work in XamlPad...Stripping the class-declaration and pasting the markup into XamlPad will successfully create windows.

[5953 byte] By [JSampsonPC] at [2007-12-30]
# 1
Hmm that is strange. Run in a debugger and check the inner exception(s) - the line number is often misleading.
neilmosafi at 2007-10-9 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 2
look at inner exception, it gives you the exact problem
leed at 2007-10-9 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 3
InnerException for Scenario A:
{"Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."}

InnerException for Scenario B:
{"Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."}

There's obviously a common-ground that is breaking both Scenario's...

JSampsonPC at 2007-10-9 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 4
Thread.Bump();
JonathanSampson at 2007-10-9 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 5
Hmm are you running from a network drive or something? See this forum post

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=561782&SiteID=1

neilmosafi at 2007-10-9 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 6
This was on the thread you suggested. It fixed my issue.
Karthikeya Pavan Kumar .B wrote:

Not sure about this..but this may help you...

Go to Control Panel / Administrative Tools / Microsoft .NET Framework
Configuration / configure security settings.
Then to My Computer->Runtime Security Policy node on the left and clicking
"Adjust Zone Security" link on the right side , give it full trust

JonathanSampson at 2007-10-9 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 7

Glad to have been of help!

neilmosafi at 2007-10-9 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...

Visual Studio Orcas

Site Classified