Open Word using a button on a web page

I am developing a proof of concept for a web application: a web page with a button that opens a Word application installed on a user's PC.

I am stuck in a C # project in Visual Studio 2008 Express (Windows XP client, LAMP server). I followed the Writing ActiveX Control in .NET and after some tweaking it worked fine. Then I added a button to open Word.

The problem is that I can reference Microsoft.Office.Interop.Word from the project, but I cannot access it from the web page. The error says: "This assembly does not allow partially trusted subscribers."

I read a lot about security in .NET, but now I'm completely lost. Disclaimer: I have been in .NET since 4 days ago.

I tried to get around this problem, but I do not see the light! I donโ€™t even know if itโ€™s ever possible!

using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; using Word = Microsoft.Office.Interop.Word; using System.IO; using System.Security.Permissions; using System.Security; [assembly: AllowPartiallyTrustedCallers] namespace OfficeAutomation { public partial class UserControl1 : UserControl { public UserControl1() { InitializeComponent(); } private void openWord_Click(object sender, EventArgs e) { try { Word.Application Word_App = null; Word_App = new Word.Application(); Word_App.Visible = true; } catch (Exception exc) { MessageBox.Show("Can't open Word application (" + exc.ToString() + ")"); } } } } 
+4
source share
2 answers

Using the .NET Framework 4 + XBAP makes this easier: you can use WPF XBAP instead of ActiveX.

And in the project settings window, do: Signing: unlock all the boxes. (this project does not need to be signed), in the "Security" section, simply change it to "Full Trust".

The user will be prompted once if he wants to run the application.

+2
source

The post How to provide additional trust for the hosted Internet Explorer build on the .NET Security Blog sheds light on this issue. It dates back to 2003, so now everything could change ... I donโ€™t know.

But the commentator asked (2006)

Is it possible to run a .net assembly with all trust resolution without changing anything on the client side? Earlier we were using a signed ActiveX in CAB, which worked fine, and tried to port it to C #.

And Schonfa answered

No, it is currently not possible to elevate the rights on the client for management. The next option is ClickOnce, which will allow you to request and pick up applications - although this application will not have a web page.

0
source

Source: https://habr.com/ru/post/1309340/


All Articles