I'm trying to build a simple Silverlight 3 MediaPlayer using the MediaElement tag:
<Border Margin="8,8,0,8" Grid.Column="1" Grid.Row="1" BorderBrush="Black" BorderThickness="1" CornerRadius="7">+
<MediaElement x:Name="FighterPilot" Source="http://localhost/repository/FighterPilot.wmv" Stretch="Fill"/>
</Border>
This works very well for low resolution wmv files. But when a WMV File that has a 720p resolution, i get the build error
Xap packaging failed:
System.OutOfMemoryException
Do anyone have any clue why I get this build error?
Thankful for any help on this one!
Update: The PC I'm developing on has loads of free RAM, so memory shouldn't be a problem.
Assuming that you are using Visual Studio and the WMV file is in your Silverlight project, set the build action on the WMV file to "None" and set "Copy to output directory" to "Copy Always". That way it will not get bundled with the XAP file.
Or you could consider putting the WMV file in a "Video" directory under the ClientBin folder in the website which you can then access using the following:
FighterPilot.Source = new Uri("/Video/FighterPilot.wmv", UriKind.Relative);
No, I've never had that problem. The easy solution would be to not include the wmv file in the Silverlight project. You could add it somewhere in the ASP.NET project instead to avoid it being packaged in the xap all together.
Related
Can anyone tell me the proper way to deploy a C# WinForms application that uses gstreamer-sharp? The only way I can get it to work is to work is by setting the gstreamer bin directory as my Application's working directory.
I have seen examples trying to temporarily set the application's path to the various gstreamer directories, but this still does not work for me and I get errors that DLL's are missing.
Environment.GetEnvironmentVariable("PATH") + ";C:\\gstreamer\\1.0\\x86\\bin\\");
Environment.SetEnvironmentVariable("PATH",
Environment.GetEnvironmentVariable("PATH") + ";C:\\gstreamer\\1.0\\");
Environment.SetEnvironmentVariable("PATH",
Environment.GetEnvironmentVariable("PATH") + ";C:\\gstreamer\\1.0\\x86\\lib\\");
Environment.SetEnvironmentVariable("PATH",
Environment.GetEnvironmentVariable("PATH") + ";C:\\gstreamer\\1.0\\x86\\");
Should I just deploy all of the gstreamer DLLs inside my application's bin driectory? I was hoping to have them run the installer and then my application could could reference it.
Any help on this would be greatly appreciated.
Adding the bin directory only should be enough. You can look at https://github.com/Vocaluxe/Vocaluxe/blob/develop/Vocaluxe/Lib/Sound/Playback/GstreamerSharp/CGstreamerSharpAudio.cs to see how initialization is done in Vocaluxe.
Probably the easiest solution I can come up with is manually putting the gstreamer bin directory in the system's PATH.
In WinForms it is possible to import an image as a resource, and the image would still work when compiled in the /bin/Debug folder.
I can't figure out how to get this working in WPF, when I run the application the image doesn't load, because the image is saved in /Projects/AppName/images/, and the application is compiled into /Projects/AppName/bin/Debug when I run it in Debug mode.
Do I simply need to make a copy of my Images folder and put it where the application is compiled? Or is there another way. Here is my code which displays my image:
<Image Width="300">
<Image.Source>
<BitmapImage DecodePixelWidth="300" UriSource="/images/jamsnaps-dark.png" />
</Image.Source>
</Image>
Create a folder (e.g. images) in your Visual Studio Project.
Add the image file(s) to that folder.
Set their Build Action to Resource (in the Properties window, see second image in this answer).
Then write the UriSource property like you already did:
UriSource="/images/jamsnaps-dark.png"
That URI is effectively a Resource File Pack URI, where the prefix is automatically added by the XAML Parser.
In code behind, you would write
bitmap.UriSource = new Uri("pack://application:,,,/images/jamsnaps-dark.png");
Two options :
1) Go out from bin/Debug and in to your application folder by ../../ and then to your image.
<Image>
<Image.Source>
<BitmapImage UriSource="../../images/jamsnaps-dark.png" />
</Image.Source>
</Image>
2) Compile your images as Content from properties in the context menu on the image file , and then when compiled they would be placed in been debug.
I don't remember if you also need to tell them to copy local also in properties ( i'm not near a computer at the moment so i can't check .
Add the image to your project directory
In the solutions explorer, right click the image and select Include in Project
Build Action should be set to Resource by default.
You can then start to use the image path relative to the root e.g. images/text.jpg if you put it in a folder called images.
I added icons to my buttons in my WPF ClickOnce app but they are missing after deployment. They show up fine in debug in Visual Studio 2012. The icons are set as follows:
Build Action: Content
Copy to Output Directory: Copy if newer
This is following another post I saw that says to do this to use them in the following way in XAML:
<Button Style="{StaticResource LinkButton}" Command="{Binding PullForwardCommand}">
<StackPanel Orientation="Horizontal">
<Image Source="pack://siteoforigin:,,,/Resources/Icons/pullfwd.png" />
<TextBlock Text="Pull Forward" Style="{StaticResource MenuTB}"/>
</StackPanel>
</Button>
I did see all the icons are shown in a folder Resources/Icons (as named in my project) where the app is published (albeit as forward.png.deploy).
How do i get the icons to show up in the deployed app?
Change the Icon properties to
Build Action : Resource
Copy to Output Directory : Do not Copy
Hope this should work
This is really weird. In Blend 4, the custom font works when I see the application in the designer, but when I run it, the font is gone and it goes back to arial or something. This is my XAML:
<TextBlock Text="Text G" FontFamily="/ProjectName;component/Fonts/#Futura Lt BT" FontSize="48" Background="#FFC44747" />
The font is in a folder called "Fonts" and the control in which I'm trying the font is in a folder called "Controls". I know it must be a problem with the relative position of the "Fonts" folder to the "Controls" folder, but I've already tried a lot of stuff and it doesn't work.
Also, the XAML markup I put up there is what Blend creates when I select the custom font. The font is copied as a resource all right (I already check the csprof file and it's there).
Any ideas? This has been kicking my butt for a couple hours now.
Thanks.
While I understand that this is far too late to help the question author, I am leaving this to help future viewers of this question.
The information in this answer comes from the Packaging Fonts with Applications page on MSDN:
Adding Fonts as Content Items
You can add fonts to your application as project content items that are separate from the application's assembly files. This means that content items are not embedded as resources within an assembly. The following project file example shows how to define content items.
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Other project build settings ... -->
<ItemGroup>
<Content Include="Peric.ttf" />
<Content Include="Pericl.ttf" />
</ItemGroup>
</Project>
In order to ensure that the application can use the fonts at run time, the fonts must be accessible in the application's deployment directory. The element in the application's project file allows you to automatically copy the fonts to the application deployment directory during the build process. The following project file example shows how to copy fonts to the deployment directory.
<ItemGroup>
<Content Include="Peric.ttf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Pericl.ttf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
Adding Fonts as Resource Items
You can add fonts to your application as project resource items that are embedded within the application's assembly files. Using a separate subdirectory for resources helps to organize the application's project files. The following project file example shows how to define fonts as resource items in a separate subdirectory.
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Other project build settings ... -->
<ItemGroup>
<Resource Include="resources\Peric.ttf" />
<Resource Include="resources\Pericl.ttf" />
</ItemGroup>
</Project>
When you add fonts as resources to your application, make sure you are setting the element, and not the element in your application's project file. The element for the build action is not supported.
The following markup example shows how to reference the application's font resources.
<TextBlock FontFamily="./resources/#Pericles Light">
Aegean Sea
</TextBlock>
Please follow the above link for details on referencing Font resources from code and other useful information.
Everywhere over the internet and in books it says that when you add a font you should set the Build Action to "Resource" (example here). And it 'worked for a while. Anyway, to fix my problem, I had to change it from "Resource" to "Content".
I'm starting an SL project in VS2010, and I'm finding that the AppManifest.xml file isn't being updated by the build. This causes the xap to fail to load in the browser, throwing an InitializationException. Doesn't VS maintain this file for you?
I noted that the Build Action listed for the AppManifest.xml file is currently "None", but I'm not sure what I should change that to, if anything.
The problem turned out to be that I didn't have any Application class in my project, nor the required App.xaml. (I had somehow deleted these files when attempting to customize the solution.) This caused the xap to fail to load, and the error message led me to believe that the root cause was the AppManifest.xml, which generates the AppManifest.xaml file.
This was a mistake. Fixing the Application class and the App.xaml solved the problem.