WPF application execution path - wpf

I have developed a WPF application and placed the executables on a network path. I have distributed the shortcut to the application to the users. Now, users can launch the WPF application by running the shortcut.
In the WPF application, I like to know from what client's drive the application was executed. In other words, I like to know the letter of the drive where the shortcut was placed. Is it possible to get this information? If yes, how?
BTW, I am aware of "Assembly.GetExecutingAssembly().Location" but this returns the path to application, not the path to shortcut.
Thanks,

To the best of my knowledge there is no way to find this out. What you could do, though, is add a command-line parameter to the shortcut stating the drive.

Related

Select an entry point with MageUI in the command line

This is related to this article but is not a duplicate.
I have a WPF app deployed via ClickOnce, and one of the projects in the solution is simple UI-less standalone Winforms app. This exe should live in the same directory of the main wpf exe. What happens after deploying is that this app runs instead of the wpf app. When I looked at the manifest, the entry point was set to the winforms app instead of the wpf app. I am not sure if its alphabetically related (the name of the winforms app is listed before the wpf one in the filesystem after deployment), but what I want to do is change the entry point in the manifest programmatically (via commandline arguments).
MageUI lets you define the entry point, just like RobinDotNet reveals, but is there a commandline switch to do this via mage.exe?
No. That's what I found frustrating with the command line version of Mage. Usually you can do more with the command line version of an app, not less. But there are several things MageUI can do that the command line version can't.
Here's what MSDN says about it...
Mage.exe will also use a simple set of heuristics to detect the main
executable for the application, and will mark it as the ClickOnce
application's entry point in the manifest.
I don't know what those heuristics are, but I would start by playing with the names of the exes. If all else fails, you can...
Generate the manifest with mage.
Modify the entry point in the manifest with your own code.
Re-sign the manifest with mage.

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.

Burn a CD from Silverlight

I have a Silverlight application with a large DataGrid. I have added the ability to export the contents of that DataGrid to Excel, PDF, and several other formats. In my export dialog, I have a checkbox that says "Burn to CD". The reason I'm trying to do this is my user base really wants to be able to export files directly to a CD.
My question is, is this even possible with Silverlight? I think I can do this through COM interop which was unveiled with Silverlight 4. But I know that COM interop is limited to Windows, because of this cross-platform support would be nixed. I guess my questions are:
Can I burn to a CD with Silverlight?
Is COM Interop "the way" to accomplish this?
Is there a way to burn to a CD from Silverlight on the Mac?
Thank you!
COM Interop is only possible within Out-Of-Browser mode and with elevated rights. Also COM is Microsoft only so you wont be able to use that with Macintosh.
Maybe you can generate an ISO or ZIP file on the server side, or even on client-side if you'd want and deliver that to the user, that way the user can decide to store it on an USB stick or burn to a CD theirself.

Does Silverlight 3 have access to local file system, Open Excel, and print reports?

I was wondering if Silverlight 3 can be used to create line of business applications where I can use file import/export facilities, read an xls file and open Excel, use a report tool like Crsytal Reports or Reporting Services or.. is WPF needed?
I am new to Silverlight and WPF and want to decide if I can skip learning WPF. I know Silverlight is a subset of WPF but I just want to concentrate in one of the two.
Although Silverlight is sand-boxed and it isn't possible to open and save files to the local file system direcly, it is possible to get a stream to a local file.
There are the OpenFileDialog and SaveFileDialog classes. These classes make it possible to let the user select a file or location. They return only a stream to that file and do not give any information about the filesystem. This way it's possible to import and export to excel for example.
This example should be enough to get you going.
update:
in the meantime I did a small SilverBullet(tm) on the subject on my blog at http://www.timmykokke.com/
Silverlight 3 has quite limited file system access. Even though you can save a local file you cannot open it using the associated application directly from Silverlight. If you want the user to export and open an Excel file from a button click in Silverlight you will have to consider alternatives:
You can open a new browser window pointed at a URL on your webserver that generates an Excel file. If the server sets the correct content type and the client is properly configured the user will be prompted to open the file in Excel. This effectively moves your export code to the server.
You can embed an ActiveX control on the same page as the Silverlight control and using the browser object you can operate this ActiveX control from Silverlight. Given enough rights by the user the ActiveX control can do anything to the local computer including automating Excel.
No, but apparently SL4 does!
Local file access - Silverlight 4
No, but unlike Jimmy my guess is that it won't happen in a future.
If you need local system there are other technologies to use (e.g. local windows service which can communicate with silverlight app).
The reason why silverlight won't have local access in the nearest future is that Microsoft learned it's lesson with ActiveX.
No, as far as I know Silverlight 3 is still as sand-boxed as ever. This is becoming a bottleneck for developers though, so I'm sure it will be addressed in upcoming versions of Silverlight.
From what I know, SL3 doenst support to use COM application such as Word, Excel, etc.. but SL4 does. If your application is just gonna be used internally, WPF will be the best candidate for your project, but if you want it to be used from the external clients as well, then I reckon you can use SL4, then use OUT OF BROWSER, then it'll work really similar with WPF. Plus with SL4, you're able to interact with Excel, Word, etc... to do lots of things.
Cheers,
Brandon

Resources