Array
(
)

WPF não funciona no meu exemplo

Pjava
   - 16 nov 2012

Estou estudando Entity FrameWork, com o livro Visual C# 2010 passo a passo, de John Sharp. Bem, comecei a fazer os exemplos, como sempre tenho feito, todos até o momento funcionaram. Esse exemplo,do Entity, está compilando sem problemas. Não dá nenhum erro. Acontece que quando vou startar o programa, ele não não sobe, parece que vai funcionar e não funciona. Não dá nenhum erro apenas não starta. Tente com F5 e CTRL-F5 e nada. Fui executá-lo fora do visual studio, startando o exe direto de sua pasta e também não funciona. O que pode estar errado? Desde j´agradeço. Tentei anexar o meu exe aqui para vocês darem uma olhada, mas não sei como anexar arquivo.

Joel Rodrigues
   - 20 nov 2012

Amigo, é que falando "esse exemplo" fica um pouco complicado para sabermos de que se trata exatamente. Se tiver algum link do mesmo exemplo na web, ajudaria.
Mas cabe uma pergunta: a aplicação tem um form inicial definido?

Pjava
   - 20 nov 2012

Sim, tem sim um form. Abaixo o código do mesmo e o XAML dele.

namespace Suppliers
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class SupplierInfo : Window
{
private northwindEntities northwindContext = null;
private Supplier suppliers = null;
private IList productsInfo = null;

public SupplierInfo()
{
InitializeComponent();
}

private void Window_Loaded(object sender, RoutedEventArgs e)
{
this.northwindContext = new northwindEntities();
supplierList.DataContext = this.northwindContext.Suppliers;
}
}

[ValueConversion(typeof(string), typeof(decimal))]
class PriceConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value != null)
return String.Format("{0:C}", value);
else
return "";
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}

}
}

<Window x:Class="Suppliers.SupplierInfo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:app="clr-namespace:Suppliers"
Title="Supplier Information" Height="362" Width="614" Loaded="Window_Loaded">
<Window.Resources>
<app:PriceConverter x:Key="priceConverter" />
<DataTemplate x:Key="SuppliersTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=SupplierID}" />
<TextBlock Text=" : " />
<TextBlock Text="{Binding Path=CompanyName}" />
<TextBlock Text=" : " />
<TextBlock Text="{Binding Path=ContactName}" />
</StackPanel>
</DataTemplate>
</Window.Resources>
<Grid>
<Button Content="Save Changes" Height="23" HorizontalAlignment="Left" Margin="12,300,0,0" Name="saveChanges" VerticalAlignment="Top" Width="133" IsEnabled="False" />
<ComboBox Height="23" HorizontalAlignment="Left" Margin="12,12,0,0" Name="supplierList" VerticalAlignment="Top" Width="568" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}" ItemTemplate="{StaticResource SuppliersTemplate}" />
<ListView Height="223" HorizontalAlignment="Left" Margin="12,41,0,0" Name="productList" VerticalAlignment="Top" Width="568" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}" >
<ListView.View>
<GridView>
<GridView.Columns>
<GridViewColumn Width="75" Header="Product ID" DisplayMemberBinding="{Binding Path=ProductID}" />
<GridViewColumn Width="225" Header="Name" DisplayMemberBinding="{Binding Path=ProductName}" />
<GridViewColumn Width="135" Header="Quantity Per Unit" DisplayMemberBinding="{Binding Path=QuantityPerUnit}" />
<GridViewColumn Width="75" Header="Unit Price" DisplayMemberBinding="{Binding Path=UnitPrice, Converter={StaticResource priceConverter}}" />
</GridView.Columns>
</GridView>
</ListView.View>
</ListView>
</Grid>
</Window>

Pjava
   - 21 nov 2012

O interessante, é que ele não para em nenhum lugar. Coloquei um Break no InitializeComponent e mesmo assim ele não parou. Não consigo debugar. Não dá erro. Apenas, parece que vai rodar, creio eu que ele faz tudo e depois volta para o design. É como se o form não startasse, para que você entendam, é como se eu quisesse rodar um serviço, como se fosse um programa. É isso que está ocorrendo.

Pjava
   - 21 nov 2012

Saída da tela OutPut. Como eu faço para acessar a Imediate Window?

'Suppliers.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Suppliers.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Suppliers.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Suppliers.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Suppliers.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Suppliers.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Suppliers.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Suppliers.vshost.exe' (Managed (v4.0.30319)): Loaded 'D:\Projetos\Suppliers\Suppliers\bin\Debug\Suppliers.vshost.exe', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Suppliers.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Suppliers.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Suppliers.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.Entity\v4.0_4.0.0.0__b77a5c561934e089\System.Data.Entity.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Suppliers.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Suppliers.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Security\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Security.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Suppliers.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Suppliers.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Suppliers.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Suppliers.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Suppliers.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xaml\v4.0_4.0.0.0__b77a5c561934e089\System.Xaml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Suppliers.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\WindowsBase\v4.0_4.0.0.0__31bf3856ad364e35\WindowsBase.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Suppliers.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\PresentationCore\v4.0_4.0.0.0__31bf3856ad364e35\PresentationCore.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Suppliers.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread '<No Name>' (0x2eec) has exited with code 0 (0x0).
The thread '<No Name>' (0x1b94) has exited with code 0 (0x0).
The thread 'vshost.LoadReference' (0x19ec) has exited with code 0 (0x0).
'Suppliers.vshost.exe' (Managed (v4.0.30319)): Loaded 'D:\Projetos\Suppliers\Suppliers\bin\Debug\Suppliers.exe', Symbols loaded.
'Suppliers.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Step into: Stepping over non-user code 'Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly'
The thread 'vshost.RunParkingWindow' (0x2044) has exited with code 0 (0x0).
The thread '<No Name>' (0x28ec) has exited with code 0 (0x0).
The program '[11552] Suppliers.vshost.exe: Program Trace' has exited with code 0 (0x0).
The program '[11552] Suppliers.vshost.exe: Managed (v4.0.30319)' has exited with code 0 (0x0).

Pjava
   - 22 nov 2012

Bem, ainda não testei, mas estudando aqui WPF, vi que está faltando ou eu com certeza fiz caca no XAML principal, faltou uns caras por lá. Vou refazer e ver se era isso mesmo. Se for volto a postar.