WPF - Copying resources on publishing - wpf

I'm developing an WPF application that has an reference of a C# Class Library.
That C# Class Library has a few XML files that i'm copying to output as embed resources.
When i debug the WPF application, those XML are copied to debug folder of WPF and the app runs properly.
But when i publish the application i get errors because the application isn't finding the resources.
I must admit i'm just now introducing to WPF, so i haven't understand yet the process of publishing and installing the application.
Those XML files should be published by VS in "Aplication Files" folder of the published folder? If yes, what i'm i doing wrong?
By the way, i'm accessing those files in my code (of C# Class Library) from AppDomain.CurrentDomain.BaseDirectory
Thanks

Are you using click once for publishing? you can define what dependencies you need and for each one where place must have.

Related

Automate compilation process for Windows Phone application and multiple variations

I am developing multiple Windows Phone applications that vary only by the content of several files. Applications share the same logic therefore I created a project and multiple folders, one for each app variation with variant's assets and files and moved them to separate location. To compile project I copy over files and follow a standard compilation process with Visual Studio.
Now there are only 5 application variations and for now it is suiting solution, but the number is expected to grow to 50 and more. I would like to automate the process and my current idea is to write a batch script to copy files from variation folder, overwrite project files, compile app with a script and to copy xap package to another location.
My two questions are:
Is my idea good resolution of the problem or is there a more graceful way to do this I am not aware of? (manage and develop multiple app variations)
How would I compile windows phone app from cmd?
I think your problem is valid. I ran into a similar requirement in the past (only that it was for Windows 8 Store Apps), and what I did was the following:
Create a "core" project and moved all the shared logic to that project. I then created a sample app project, referenced the core project and made sure the sample app worked the way I wanted it to.
Finally, I converted the sample app into a Visual Studio template. What this basically does is take the project code and create a Visual Studio template you can reuse.
Read more about it here.
Some work needed to be done within the template source code in order to get some of the dynamic parts like app name into specific locations within the code. For example, you can change a class namespace to be the project's namespace by applying the following code in tour class:
namespace $safeprojectname$
You can read more about template parameters here.
Hope it helps.
To compile windows phone applications or any .NET app from command line you should use
msbuild.exe
. You can find more information and samples here.

Microsoft.EnterpriseManagement.CompositionEngine and Microsoft.EnterpriseManagement.Presentation.Core cannot add to Silverlight Project

I am authoring a management pack with custom views using Silverlight / WPF (shared code) and MP authoring console and MP authoring tool in Visual Studio.
I am following this tutorial on custom views.
Widget for SCOM operation and web console - custom
In Section 4.1: It mentions: Add a reference to Microsoft.EnterpriseManagement.CompositionEngine and Microsoft.EnterpriseManagement.Presentation.Core assemblies. These can typically be found in the Console folder of the Operations Manager installation. Attention: the assemblies from the RTM/CU1 installation will not work! You need to download the sample project files and use the included assemblies.
I cannot add references to the Silverlight project. I get an error message:
Is there any way to get around this?
I understand that the .net runtime is different than that of Silverlight. Yet, this tutorial shows a working example, so it there a missing step or a different binary. What am I missing?
In Section 4.1: It mentions: Add a reference to Microsoft.EnterpriseManagement.CompositionEngine and Microsoft.EnterpriseManagement.Presentation.Core assemblies. These can typically be found in the Console folder of the Operations Manager installation. Attention: the assemblies from the RTM/CU1 installation will not work! You need to download the sample project files and use the included assemblies.
The important bit is the bit in bold, you need to download the sample project and copy the references from there. Were you doing this?
http://gallery.technet.microsoft.com/Creating-a-Widget-for-104711ac
If you download this zip and go to the following sub directory
\Creating a Widget for Operations Manager Dashboard - Walkthrough %231.zip\Creating a Widget for Operations Manager Dashboard - Walkthrough #1\Section_4\AlertSummarySilverlight\Bin\Debug
You'll see the two assemblies in this folder. Copying them out of the zip into another folder and add a reference to them. This works for me in Silverlight 5.

Localization of a WPF ClickOnce application with LocBaml

I'm trying to use the LocBaml way (this might be my mistake) to localize a WPF application, but this application is deployed with ClickOnce and the publishing process doesn't pick up the localized .resource.dll.
I do add the files to my ClickOnce manifest, and I can see that this part works because when I launch the application, I get an error saying that the application can't find fr\LocalizationTest.resource.dll. (So at least it knows it should be there...)
The normal way to include a file in a ClickOnce application is simply to add it in the Project Properties -> Publish -> Application Files menu, but my localized resources are not in there.
What can I do ?
Turns out adding a dummy Resources.fr.resx in the Properties folder fixed the problem. With that the publishing process picked up the translated .dll and the ClickOnce application worked as expected.

How to make an setup just like Devexpress installation (v11.1.8)?

I want to pack my file in to a single executable file "setup.exe", my application is written in c# and WPF, I know that there are a lot of applications out in the store for creating a installation pack, but the point is which one would help me to build my installation pack just like Devexpress dose ?
For an UI similar to DevExpress you will need a setup authoring tool which offers an external UI and rich graphics.
Advanced Installer and InstallShield have some great UI themes which can get you started. You can also find a list of setup tools here:
http://en.wikipedia.org/wiki/List_of_installation_software
You'll probably have to roll a custom solution for this one. I expect nothing less of the Devexpress team then creating their own installer.
If you're application is not heavily bound into the registry and all kind of windows folders it should not be that hard to create an application that extracts some files into a directory and create some great UI while copying.

How to reuse Silverlight projects in WPF?

I would like to use the same project (class library) in Silverlight and WPF. So, I started as a Silverlight Class Library.
But the problem is: some of the common classes (i.e. Point, TouchAction) exists in different assemblies and compiler is showing the following error when I add the reference of Silverlight class library to WPF project.
The type 'System.Windows.Point' exists in both 'c:\Program Files\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\System.Windows.dll' and 'C:\Program Files\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\WindowsBase.dll'
Can anyone please suggest a work around?
You can try Prism 2.0 approach:
Have two sepparated projects, but link files from one to another. Pieces that are specific to one platform can be sepparated in conditional compilation (#ifdef _SILVERLIGHT ... #elseif ... #end)
Check out the Multitargeting quickstart for more details (though all Quickstarts plus the Reference Implementation have Silverlight & WPF versions, the multitargeting sample is the simpliest one if you only want to share code between platforms).
In the same project, you'll find the Project Linker tool (though it only works in VS2008 as far as I know) which automatically keeps two or more projects synced-up by adding links automatically when new items are added to the source project.
Hope this helps!

Resources