-1

error listI am new in wpf, i am developing a very simple application using the same. I have a window in which i have put a dockpanel, the dockpanel has two menus,

"Action->About,Help,Exit" & "Area-> Area1, Area2,Area3"

On clicking area1 in area menu i load a user control in the same window. This user control has a grid. whole grid is divided into 40 rows & 40 columns, the background of the grid is an image such that it spans the whole grid. Actually the idea i to divide the image into 160 equal squares which are clickable. in each cell of the 40 cross 40 grid i put a transparent button with incremental names like b1,b2,b3...upto b160. On clicking any button the method anybuttonclick is executed (which i defined in the code behind) i also have 160 separate high resolution images in a separate folder in the solution directory, the names of all these image are also put as b1.jpg,b2.jpg,b3.jpg.. upto b160.jpg !!! in code behind i have put anybuttonclick method in which i get the name of the button that the user has clicked and with the help of this I am able to decide which image to load in the new window. Eg if user click b35 I load the image b35.jpg in the new window.. this image in the new window is the high resolution image (the zoomed version of cell 1).

The same thing I have down with area2.. Upto here the size of images in area1 folder is 670 mb and number of images is 160 And the size of images in area2 folder I 785 mb and the number of iamges is 160

Everything works correctly. The problem arises only when I try to do the same for area3. i.e when I try to copy high resolution images for area3 into a folder named “ images3” Number of images in area3 folder Is 160 and size of images is 783 mb I get errors sometime saying outofmemory exception on runtime. Sometime it says insufficient memory to continue execution. Then I delete the images for area3(there are 160 images for each area ) I am able to debug the project properly. I tried to publish the app with only two areas. And tested on my system. It works fine.(intel core i5 2.4 ghz 16 gb ram windows 7 32 bit, visual studio 2012) But when I traferred the same published application to my laptop (intel core i7 2.4 ghz , 4 gb ram windows 7 32 bit, visual studio 2012) the application crashes on install.

My question is what I wrong with wpf? Is there any limit to the no. of images or size of images that we can work with? I tried applying hotfix to v2012 still the same issue. What is the best practise to develop such an application as in when it comes to having lot of images in your solution directory.i don’t want to use sql for storing image because I don’t want to compromise on image quality.

code in DalLake.xaml

<UserControl x:Class="HmiLike.Pages.DalLake"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:pages="clr-namespace:HmiLike.Pages"
             mc:Ignorable="d" 
             d:DesignHeight="800" d:DesignWidth="800"
             >


    <Grid>
        <Grid.Background>
            <ImageBrush ImageSource="/Images/background.jpg">

            </ImageBrush>
        </Grid.Background>
            <Grid.ColumnDefinitions>

        <ColumnDefinition Width="50*"/>
            <ColumnDefinition Width="44*"/>
            <ColumnDefinition Width="42*"/>
            <ColumnDefinition Width="44*"/>
            <ColumnDefinition Width="45*"/>
            <ColumnDefinition Width="45*"/>
            <ColumnDefinition Width="44*"/>
            <ColumnDefinition Width="44*"/>
            <ColumnDefinition Width="43*"/>
            <ColumnDefinition Width="47*"/>
            <ColumnDefinition Width="44*"/>
            <ColumnDefinition Width="42*"/>
            <ColumnDefinition Width="45*"/>
            <ColumnDefinition Width="13*"/>


        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>

            <RowDefinition Height="50*"/>
            <RowDefinition Height="46*"/>
            <RowDefinition Height="44*"/>
            <RowDefinition Height="42*"/>
            <RowDefinition Height="45*"/>
            <RowDefinition Height="45*"/>
            <RowDefinition Height="44*"/>
            <RowDefinition Height="44*"/>
            <RowDefinition Height="43*"/>
            <RowDefinition Height="46*"/>
            <RowDefinition Height="45*"/>
            <RowDefinition Height="41*"/>
            <RowDefinition Height="45*"/>
            <RowDefinition Height="45*"/>
            <RowDefinition Height="45*"/>
            <RowDefinition Height="44*"/>
            <RowDefinition Height="46*"/>
            <RowDefinition Height="11*"/>

        </Grid.RowDefinitions>

        <Button Grid.ColumnSpan="1" Content="" Grid.Column="5" Grid.Row="0" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_001" Click="anyButtonClicked" />
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="6" Grid.Row="0" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_002" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="7" Grid.Row="0" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_003" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="4" Grid.Row="1" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_004" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="5" Grid.Row="1" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_005" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="6" Grid.Row="1" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_006" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="7" Grid.Row="1" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_007" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="8" Grid.Row="1" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_008" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="4" Grid.Row="2" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_009" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="5" Grid.Row="2" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_010" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="6" Grid.Row="2" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_011" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="7" Grid.Row="2" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_012" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="8" Grid.Row="2" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_013" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="9" Grid.Row="2" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_014" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="4" Grid.Row="3" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_015" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="5" Grid.Row="3" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_016" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="6" Grid.Row="3" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_017" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="7" Grid.Row="3" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_018" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="8" Grid.Row="3" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_019" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="9" Grid.Row="3" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_020" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="2" Grid.Row="4" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_021" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="3" Grid.Row="4" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_022" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="4" Grid.Row="4" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_023" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="5" Grid.Row="4" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_024" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="6" Grid.Row="4" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_025" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="7" Grid.Row="4" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_026" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="8" Grid.Row="4" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_027" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="9" Grid.Row="4" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_028" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="10" Grid.Row="4" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_029" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="11" Grid.Row="4" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_030" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="1" Grid.Row="5" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_031" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="2" Grid.Row="5" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_032" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="3" Grid.Row="5" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_033" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="4" Grid.Row="5" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_034" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="5" Grid.Row="5" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_035" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="6" Grid.Row="5" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_036" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="7" Grid.Row="5" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_037" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="8" Grid.Row="5" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_038" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="9" Grid.Row="5" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_039" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="10" Grid.Row="5" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_040" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="11" Grid.Row="5" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_041" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="12" Grid.Row="5" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_042" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="1" Grid.Row="6" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_043" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="2" Grid.Row="6" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_044" Click="anyButtonClicked"/>
        <Button Grid.ColumnSpan="1" Content="" Grid.Column="3" Grid.Row="6" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_045" Click="anyButtonClicked"/>









        <!--<CheckBox  Content="2003:IKONOS" Name="y3" HorizontalAlignment="Stretch"  Grid.Row="1" VerticalAlignment="Center" Grid.Column="1" Height="auto" Width="auto"   Style="{StaticResource myCheckboxStyle}" Grid.ColumnSpan="4" FontWeight="Bold" FontSize="18" Foreground="White"/>-->
        <RadioButton  Content="2003:IKONOS" Name="y3" HorizontalAlignment="Stretch"  Grid.Row="1" VerticalAlignment="Center" Grid.Column="1" Height="auto" Width="auto"    Grid.ColumnSpan="4" FontWeight="Bold" FontSize="18" Foreground="White"/>
        <!--<RadioButton Content="2007:QUICKBIRD"  Name="y7"  HorizontalAlignment="Stretch"  Grid.Row="2" VerticalAlignment="Center" Grid.Column="1" Height="auto" Width="auto"    Grid.ColumnSpan="4" FontWeight="Bold" FontSize="18" Foreground="White" />-->
        <RadioButton Content="2014:GEOEYE"  Name="y14" HorizontalAlignment="Stretch"  Grid.Row="3" VerticalAlignment="Center" Grid.Column="1" Height="auto" Width="auto"   Grid.ColumnSpan="4" FontWeight="Bold" FontSize="18" Foreground="White" />
        <pages:SwitcherMenu Grid.Row="0" Grid.ColumnSpan="30" Height="20" VerticalAlignment="Top" Width="auto"/>



    </Grid>
</UserControl>

code in DalLake.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace HmiLike.Pages
{
    /// <summary>
    /// Interaction logic for DalLake.xaml
    /// </summary>
    public partial class DalLake : UserControl
    {
        public DalLake()
        {
            InitializeComponent();
        }
        private void anyButtonClicked(object sender, RoutedEventArgs e)
        {

            //CHECKING WHICH CheckBox isChecked

            if (y3.IsChecked == true)
            {


                var source = e.OriginalSource as FrameworkElement;

                if (source == null)
                    return;
                Year2003 Year2003_Window = new Year2003();


                string imagename = "Images\\"+"Dal\\"+"y3\\" + source.Name.ToString() + ".jpg";
                //Year2003_Window.win2label.Content = imagename;
                Year2003_Window.gridimage.Source = new BitmapImage(new Uri(imagename, UriKind.Relative));
                Year2003_Window.Show();


            }
            //else if (y7.IsChecked == true)
            //{

            //    var source = e.OriginalSource as FrameworkElement;

            //    if (source == null)
            //        return;
            //    Year2007 Year2007_Window = new Year2007();


            //    string imagename = "Images\\" + "Dal\\" + "y7\\" + source.Name.ToString() + ".jpg";
            //    //Year2007_Window.win2label.Content = imagename;
            //    Year2007_Window.gridimage.Source = new BitmapImage(new Uri(imagename, UriKind.Relative));
            //    Year2007_Window.Show();

            //    Year2007_Window.Show();
            //}
            else if (y14.IsChecked == true)
            {

                var source = e.OriginalSource as FrameworkElement;

                if (source == null)
                    return;
                Year2014 Year2014_Window = new Year2014();


                string imagename = "Images\\" + "Dal\\" + "y14\\" + source.Name.ToString() + ".jpg";

                Year2014_Window.gridimage.Source = new BitmapImage(new Uri(imagename, UriKind.Relative));
                Year2014_Window.Show();

                Year2014_Window.Show();
            }



        }
    }
}

heres the code in the manifest file which i added

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">

        <requestedExecutionLevel level="asInvoker" uiAccess="false" />
      </requestedPrivileges>
    </security>
  </trustInfo>

  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>

    </application>
  </compatibility>



</asmv1:assembly>
  • The problem is not in WPF. There are no limits on number or size of used images, if used correctly. To clarify what you are asking: 1) there are 3 large images 2) if the user clicks on a part of the image a zoomed in version is shown 3) after adding the zoomed images for the 3 image you run out of RAM right? What application crashes yours or VS? The problem might be in the way you load the images, but I can't tell from what you have given. Please add some source code; especially anybuttonclick – ChronosMOT Jan 20 '16 at 15:52
  • I have added the image and the codes. Thanks for your help – Asim Gulzar Jan 21 '16 at 06:44

1 Answers1

0

Your Visual Studio crashes when it tries to create the manifest file, because your manifest file gets to big.

According to this article you should change the build mode of your images.

I would try the build mode "resource", but I can't test this.

Community
  • 1
  • 1
ChronosMOT
  • 341
  • 5
  • 17
  • Hi, I cannot see my .manifest file anywhere. I went to project properties and it says "embed manifest with default settings" – Asim Gulzar Jan 22 '16 at 14:25
  • i added a new app.manifest file and but i cant c the option that would let me change build mode for my images – Asim Gulzar Jan 22 '16 at 14:41
  • Look into the links. The build option has to be set for each image. – ChronosMOT Jan 22 '16 at 16:12
  • The images were already set to "resource" i set their build property to "content".. i see the images are not displayed in while debugging the project but they are displayed when i deploy it with one click install. this has been of great help. thanks for your patience and help again. – Asim Gulzar Jan 23 '16 at 08:40
  • After setting the images as resources , the application works well but when I publish it. The images a're copied as files to the publish folder. I don't want that. Kindly help me.. – Asim Gulzar Jan 27 '16 at 06:56
  • Try setting 'Copy to output directory' to 'copy always' or 'copy if newer' – ChronosMOT Jan 29 '16 at 08:34
  • After publishing my project the image folder is also supplied with the one click install as raw images folder. Only the images names are being changed as image001.deploy. image002.deploy. & so on. Anyone can open those images with Photoshop or even ms paint. I don't want the client to know my solution structure and also the client shouldnt be able to open images in some software. Kindly help me here. – Asim Gulzar Jan 29 '16 at 09:02
  • To counter act that I'd put them in a zip file, change the extension to .packet or something along those lines, and load them in the code behind. The .packet would be added to the project as resource or content, really doesn't matter at that point. But that is going to be a pain, sorry. – ChronosMOT Jan 29 '16 at 15:31