XBAP WPF Application Unable to Access Settings Within app.config - wpf

I have an XBAP WPF application that has been working for some time now. I am recently having problems accessing settings within the app.config.
Direct references to AppSettings return empty strings, and System.Configuration.ConfigurationManager.AppSettings.Count returns 0. Also, when trying to access a web service reference I get a "Could not find default endpoint element that references contract" error.
The app.config is copied to app.exe.config when running the application and there do not appear to be any differences.
Is anyone aware of any reason this might happen? The only change is that I have recently upgraded to a Windows 7 machine. Could I be missing a component? A colleague has run the same application on his machine with the same operating system with no problems.
Thanks.

Related

Windows presentation foundation host crashes

we are using a saas application that uses WPF. it usually work fine on every browser we use
but one of our user recently was transferred to a different office and from that day he gets an error on IE 8 about WPF encountered a problem and the application crashes. same for the other browsers.
could it be connected to the network he wired to?
I am Exactly getting the same error.
A some of the forums suggest registry access problem but when I run the tool it says no problem with access.
I guess my website response is XML which is some how not been interpreted by IE.

How do I deploy a 3D Silverlight 5 web application to a third-party hosting server?

What I want to do
I've been playing around with the newly released Silverlight 5 and Silverlight 5 Toolkit (December 2011), and I would like to try deploying my 3D Silverlight test application to a third-party hosting server (AppHarbor in my case, but I'm open to other options).
My test application is simply the default Silverlight 3D application that you get when you create a new Silverlight 3D app:
Blog: http://blogs.msdn.com/b/eternalcoding/archive/2011/12/10/silverlight-toolkit-september-2011-for-silverlight-5-what-s-new.aspx
It looks like AppHarbor (and most other hosting sites) require that you copy the required Silverlight 5 DLLs into your project, because they don't have the required SDKs/Toolkits installed on their servers.
Seems fine in theory, but I have no idea how to actually do this with Silverlight.
The problem
The problem is two-fold:
I'm not sure exactly which DLLs need to be manually copied into my project, and I'm not sure how they should be included and referenced.
After some experimentation with copying a few of the Silverlight XNA DLLs into my project and referencing the local project DLLs (instead of the SDK-installed and Toolkit-installed DLLs), the basic 3D Silverlight app now crashes when I run it in the browser -- locally. (The Silverlight plugin crashes.) I didn't have this problem before I started fiddling with the references and DLLs; the default project works just fine. So I haven't even gotten to deploying to a hosting server, because it no longer runs locally.
An aside
On the latter point above (Silverlight plugin crashing), the issue seems to be related to the 3D Silverlight functionality, which apparently requires elevated trust/permissions -- admittedly, I don't fully understand how that all works yet.
Generally speaking -- irrespective of all of this DLL/reference fiddling -- it seems like I need to check "Require elevated trust when running in-browser" in the Silverlight3dApp project properties to get the spinning 3D cube app to show up in the browser. Alternatively, if I leave that unchecked, I need to manually right-click the Silverlight 5 app in the browser and enable 3D graphics on the Permissions tab. (Side note: I'm interested in how this will effect my end-users if I ever do get this deployed. Will they have to manually adjust permissions in the same way? Anyway, that's a question for a different day.)
The point of this aside:
The Silverlight plugin does not crash if I leave everything the way it is by default.
If I copy the Silverlight DLLs into my project and reference them locally, the Silverlight plugin crashes if 3D permissions are enabled.
If I copy the Silverlight DLLs into my project and reference them locally, the Silverlight plugin does not crash if 3D permissions are disabled.
The question
Has anyone successfully deployed that basic Silverlight 5 3D app to a server without Silverlight 5 (and the Silverlight 5 Toolkit) installed?
How did you do it? What files need to be copied into my project and referenced locally? Which references (if any) need to be removed?
Sub-question: If anyone has any insights about the elevated trust/permissions issue, I would love to hear those as well.
For AppHarbor I create a folder in the Silverlight project (lib) and copy all assemblies that I am dependent on and mark all the assemblies with copy to output.
Next I use subst to make a virtual drive that points to this folder and I add all the references to the assemblies on that virtual drive. (This is not needed for AppHarbor but this way I can check out my code to any folder on any machine I want without messing up the paths)
Note that you also need to add these dll's to the repository (git/mercurial) because a standard .hgignore file will skip the *.dll files.
Have you verified you are running the latest runtime for Silverlight? Did you have a previous developer runtime installed? http://www.microsoft.com/getsilverlight/get-started/install/
Hmm... I'm going to go with the above answer. I'm using the latest Silverlight 5 runtime and Silverlight 5 Toolkit and have not had any issues. Here's an app where I'm loading and animating an FBX model in Silverlight (it does require you to right click and set the permissions) and it works fine:
http://www.dustinhorne.com/necodecamp.html
As an aside I'm wrestling with whether to run in elevated trust or force the user to allow 3D acceleration. Personally I hate making the whole app elevated trust just for the 3D stuff from a security standpoint, although if you want to run it out of browser you may want to do that anyway and sign the app with a code signing certificate.

"Object reference not set to an instance of an object" error shows when adding a reference to a WCF service to a Silverlight 4 project

I have a Silverlight enabled WCF service, and a Silverlight 4 project that references it.
The service used to work nicely until I merged some changes another developer made into the service, since then the Silverlight project failed to call the service with "Server not found" error.
I removed the reference to the service, tried to add it again but this failed with error "Object reference not set to an instance of an object".
This is not limited to the above service anymore, this error happens every time I try to add any WCF service to the Silverlight project.
I am using Visual Studio 2010 and the .NET Framework 4.0 for all projects.
This problem has happened before and I was able to solve it be creating a new solution, creating fresh projects in it and then adding the code files to the projects one by one. However, this is a nightmare now that my solution contains dozens of projects and hundreds of code files.
anyone out there with a fix for this? I googled this a dozen times and all I got was fixes to similar problems that happened with Silverlight 2 and Visual Studio 2008, but these fixes didn't work for me.
Thanks.
Make sure your WCF service is working properly. Right click on the SVC file and select View in browser. If there is a runtime problem, that should point you in the right direction.
Have you tried switching WCF tracing on? I find it normally provides clues to the problem source. Also, have you checked your Silverlight client config? Are the end point addresses all correct?

Understanding Silverlight

I've just started learning Silverlight and I learned it is a client side program. Suppose I write a Silverlight app and add it to a webpage which is hosted on my desktop. If in the code-behind, I iterate through all the files in C:\StackOverflow and display the results on the page, when a user visits the page from another computer, will the program look for C:\StackOverflow on his computer, and not mine?
That's correct, the Silverlight content is executed on the client computer.
However you wouldn't be able to access C:\StackOverflow because the plugin is sandboxed for obvious security reasons.
You don't have access to the local file system directly within a Silverlight application since the application could compromise the system; it is abstracted away.
An OOB Silverlight application has increased trust but still does not provide complete access to the file system as would a WinForms or WPF application.
usually the Silverlight application will be hosted on some server..
you can send to the client data from the server
and you can access your own folders through the server (if it's on your computer)
Be aware to don't confuse ASPX code-behind and XAML code-behind.
The first one executes on the server (and in your case, if correct privileges are granted, will show files on your computer).
The second one executes on the client, AFTER the download of the applet. Unfortunatly it can't list such folder, because of security resctrictions.

Minimum requirement users must have to run a simple WPF browser application?

I am thinking of making a website using a WPF browser application, but would like to know the minimum requirement a client/internet user must have to access this website made by using WPF.
Please state even the very basic requirements, like does he need to run Windows or will even Mac and Linux do, with any browser to view the application?
Three main requirements:
User has to run the application under Windows;
The browser should be either Interned Explorer or Firefox;
The .Net Framework should be installed on user's machine.
One requirement is to have the .NET framework installed (same version as you used to build your application), so that means it will only run under Windows.
Also I think only Internet Explorer and Firefox support XBAP applications.
Also I assume that you know there is a lot of restrictions for you, the developer, on what is allowed or not compared to a full trust program. For example, the file system and registry among other things are restricted in a WPF browser application.

Resources