2

I am trying to use activeX to start a windows form application written in C# from my ASP.net website. When I click a button I would like a new page to open up and activeX on that page would call my windows application.

I am using Visual Studio 2010. I have followed this tutorial: http://dotnetslackers.com/articles/csharp/WritingAnActiveXControlInCSharp.aspx

However, that tutorial is only for 1 C# file which you compile via console.

My questions are the following:

1.How would I compile the entire windows form project to use the /t:library and regasm?

2.I have followed this question answer to modify my windows form application: How do I create an ActiveX control (COM) in C#?. However, like in both examples, they do not have a Main method. When I tried to modify the code of my windows form app, I get the error saying the program does not have a Main method for entry if I take it out and replace it with a Launch() method. I am sure I am missing something?

3.Would I just write the java script on the new .aspx page to access the application?

P.S. I am trying to open this open source windows form application: http://www.codeproject.com/Articles/239849/Multiple-face-detection-and-recognition-in-real-ti

Thank you kindly

Community
  • 1
  • 1
Iuli
  • 121
  • 1
  • 4
  • 12

3 Answers3

0

You can not do that. It would be huge security risk to allow websites to execute arbitrary code on local machine, outside of some sandboxed environment (like JavaScript for example).

AFAIK closest thing to what you want is ClickOnce, that is a installer and use it to install your WinForms app on client machine. It's easy to make installation for project, just right click in VS and publish.

Antonio Bakula
  • 20,445
  • 6
  • 75
  • 102
  • I believe that's why the OP mentioned they were trying to use ActiveX. – Shawn Steward May 04 '12 at 21:20
  • as I understood question is how to use ActiveX to open win forms app, he can't do that – Antonio Bakula May 04 '12 at 21:22
  • Yes I would like to open the win form app (the open source in the link I gave) via my asp.net website. In the first link (the tutorial) they use activex control to open their c# code. But I do not know how I could use something similar to open the windows form app. I notice you mentioned it's a huge security risk. However, this project is for a class at school. Security risk is not a concern for this class. – Iuli May 04 '12 at 21:27
  • Well you can try to make ActiveX control that will duplicate functionality of that winforms app, but that will work only in IE, and ActiveX controls are not enabled in default settings – Antonio Bakula May 04 '12 at 21:30
  • I do not really understand how I would do that. All I know about ActiveX is what that tutorial presented – Iuli May 04 '12 at 21:47
  • it's not easy, try to google for activex examples. But don't do that, it's a dead technology and for a good reasons. Why not simply put that winforms app for download and put instructions on your site how to run it. Or better use ClickOnce to install winforms app : http://en.wikipedia.org/wiki/ClickOnce. – Antonio Bakula May 04 '12 at 21:57
  • The end objective of this would be that once the windows form application starts (which is the face recognition), once it recognize a user (his name) the ASP.Net would then login with that user. So once the windows form application would start, then at some point (after recognition) it would need to go back to the website and login the user. – Iuli May 04 '12 at 22:05
  • This link: http://startrinity.com/VideoRecognition/FaceRecognition/FaceRecognitionSourceCode.aspx shows very nice how it would be nice to work. Unfortunately I do not understand the implementation at all from the sample code they provide, and how I could implement something similar to my asp.net web page. They don't have any tutorials. I explored the project with Visual Studio but I couldn't understand how it gets implemented. – Iuli May 04 '12 at 22:07
  • That link is for silverlight library, don't have anything to do with your question about winforms app, ask another question – Antonio Bakula May 04 '12 at 22:18
  • Well the silverlight was an alternative, but since I do not understand it, I would still look somehow to launch the win form app. Would ClickOnce could have the effect I am looking for if I try to do it with that? Login in ASP.net via the winform app? – Iuli May 04 '12 at 22:19
  • yes, send url with crypted credentials in params to browser, http://stackoverflow.com/questions/58024/open-a-url-from-windows-forms – Antonio Bakula May 04 '12 at 22:25
  • Am I understand this correct: Use ClickOnce to open the WinForm App. Once the application recognize a user, use the Process.Start with the link and params to the login page? That page would only require the username (the name of the recognize person) and authenticate? – Iuli May 04 '12 at 22:33
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/10901/discussion-between-antonio-bakula-and-iuli) – Antonio Bakula May 04 '12 at 22:34
0

I would suggest you can create ActiveX control instead of a Windows Form. You can create it using legacy VB (VB 6.0). You can refer something like

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
MyGuruG
  • 21
  • 1
0

There is a solution that you may be able to use called ClickOnce.

http://msdn.microsoft.com/en-us/library/t71a733d%28v=vs.100%29.aspx

I've created enterprise applications that I deploy to an internet accessible location and link my users to the "publish" website that allows them to click, install, and run the application.

Keep in mind that this will install the application in addition to running it, so if part of your requirements is to not install it, then ClickOnce won't work for your scenario.

Justin Skiles
  • 9,373
  • 6
  • 50
  • 61
  • Unfortunately I need for the form to be interactive (once the program recognizes a face it will login that user). – Iuli May 07 '12 at 04:37