WPF C# System.Deployment Problem - wpf

I'm developing an XBAP application in C# and want to be able to use the System.Deployment object methods. In the object browser, I'm able to see all the object, when I try and access these methods via the code, it will not work and states that the methods are not in the name space.
Any suggestions?

Not sure if this is your issue but are your XBAP running in "full trust mode" or not?
By default, XBAPs are sandboxed...
Here is a article on how to make your XBAP full trust
More information
Windows Presentation Foundation Security Sandbox

Related

Create a .dll from a Silverlight Web Application

I programmed a Virtual Keyboard (On Screen Keyboard) as a Silverlight Web Application, now I want to use this Keyboard in an other Silverlight Application (call the Keyboard when clicking a Textbox). I thought I could create a .dll and use this in my other Application.
So is it possible to create a .dll File from a Silverlight Web Application?
Thank you for reading,
Knut Hansen
You simply need to convert it into a Silverlight Class Library. There are some things to look out for, but it isn't too hard.
It is one of the options when you create a new project in Visual Studio.
See Microsoft's documentation for more info:
http://msdn.microsoft.com/en-us/library/cc838164(v=vs.95).aspx#silverlight_class_library_project
also you can think of a web service, in this way your application can be used by anyone else, of course you can specify users of your app. I think web services are more recent and using them is more future-oriented, give it a go!

Silverlight and Full Trust Issue

We are planning to build a new integration component that can provide us access to user's machine installed apps from our web site.
The first word that came to me was ActiveX, but our expertise with the technology was not the best in the past.
Thinkink a lit bit more, the work Silverlight also came to my head, but the full trust thing was one of the few things I remembered reading about the technology..
The question is: is there a way that Silverlight (2, 3, 4, whatever) can run as a full trusted application from within the browser?
Links are appreciated.
Filipe
Unfortunately, no. Full trust is a feature of Silverlight 4, currently in beta, and is restricted to out-of-browser applications.
Additionally, full trust SL4 applications do not have unrestricted access to the system (particularly file system), though this may change before before release (if I have anything to do with it).
Edit: If you are considering ActiveX (which is Windows/IE only), you might want to have a look at WPF, since it can run full trust from the browser (if it's in a trusted zone).
No, like Richard said, this is not at all possible inside the browser, even in SL4. There is a sandbox, and you live in it. You can talk to web services, other Silverlight applications or the browser.
By talking to the browser, I mean you can talk to the DOM and the Javascript engine. We needed to launch a Windows application and communicate to it via Silverlight. We accomplished this by putting a small ActiveX control in the web page. It is responsible for launching the WinForms application and handling inter-process communication to it.
This method has many drawbacks: It can only work in IE, and it only works in Windows. You might also run into permissions issues. The ActiveX component needs to be installed along with the desktop application, or as an additional download. The deployment story there is pretty awful, if you ask me.
In our case, the analysts were willing to deal with the restrictions for the re-usability of an existing application, and we consider it to be an optional feature.
Does it have to be a web application? sounds like you want a desktop app. It can be easiliy distributed with one Click deployment. Will work on windows only but since you were considering ActiveX sounds like that's what you need.
Well - if you're hosting the silverlight control from an ASP.NET application - Believe you have access to
Request.ServerVariables["AUTH_USER"];
...and you can pass that on to your control as a parameter.
D

Can Silverlight communicate with a MIDI instrument?

Can Silverlight communicate with a MIDI instrument connected to the machine running the Silverlight application? In- or out-browser.
It appears that this is not possible in Silverlight. To communicate with a MIDI device, you would have to PInvoke methods in winmm.dll, and this (apparently) cannot be done in Silverlight. See:
http://forums.silverlight.net/forums/t/123673.aspx
This could be done easily in a WPF or WinForms application. It could also be done in a browser with XBAP, although you would need elevated permissions to access the winmm API, which would require a certificate. You can also still make ActiveX controls with .Net, but I think you would still need a certificate for this to get the proper permissions (although it might work with just a scary security confirmation dialog).
It's not possible to use .NET code directly in Silverlight because Silverlight has a different core.
All .NET classes that you want to reference in Silverlight need to be recompiled for Silverlight.
It's also not possible to access the underlying hardware directly, so i'm afraid you're stuck with a full-trust XBAP(you need to sign your app and the user will get an popup asking for permission). XBAP gives you all the .NET capabilities while running in the browser. XBAP will run on firefox/internet explorer on any >xp machine with .net 3.0 installed.
Hope this helps.
Silverlight 3 has an extensible multimedia pipeline for audio and video. You can procedurally create your own audio and play it. To implement what you want, you would have to write your own midi synthesizer.

How do I run a Full Trust XBAP on intranet?

I've made a WPF Browser Application that hosts old WinForms controls (I haven't migrated fully to WPF yet). Using WindowsFormsHost means my Browser App requires Full Trust to run. This is not a problem for me since this app is only meant to be run on the intranet at my company. However, after I deploy the xbap to a network share, it refuses to run, saying "Trust not granted".
What are the methods I can use to grant Full Trust to XBAP applications stored on my companies intranet?
So far, I've found 2 ways to do this. Through a really complicated method of installing certificates on the target machine.
Or through a simpler method, which is only suitable for intranets here:
Deploy a custom CLR Security policy
that modifies the default
permissionset for the given zone
So I did just that, and it works. Here's the detailed steps how I got it to work:
Open Control Panel > Administrative Tools > .NET Framework 2.0 Configuration
Expand Runtime Security Policy > Machine > Code Groups > All_Code
Right Click All_Code and click New…
Create a new code group, I named mine MyProject_FullTrust_Zone
Choose the URL condition type and specify the path on the network where the apps will be deployed.
Choose Use Existing permission set, and set it to Full Trust.
Now the only problem with this method, is that I have to deploy this change to hundreds of machines. So maybe there's still a simpler way to do this?
It will be possible in .Net 4.0 planning to be released in the first half of 2010. It is now in a beta phase, but it comes with a go live license which allows you to 'go live' even with a beta version of the .Net framework.
Although I haven't tried this, is the path to the XBAP added as a trusted site?

Using Logging from Microsoft Application Block with WPF

I have a WPF application and I want to use the Microsoft Application Block for logging (MIcrosoft.Practices.EnterpriseLibrary.Logging)
How can I configure it in order to work?
It depends where and how you want to persist the log data.
Download the enterprise lib 4.1 from
http://msdn.microsoft.com/en-us/library/dd203099.aspx
There is quick start for logging. The app.config within the sample is what you are after.
You shouldn't have to make much change from it in order to make your WPF logging works.
FYI there's nothing special about using EntLib with a WPF application versus a WinForms or server application (assuming you're not launching forms for visual tracing).
MSDN has a document on this that should answer you question:
Integrating the Logging Application Block with WCF Applications
http://msdn.microsoft.com/en-us/library/ff648685.aspx

Resources