none
Calling a Windows App Project from a Web App Project from the same solution RRS feed

  • Question

  • I have a Windows Applications Project. I created a new Web Application Project under the same solution and I am too call the Program.cs of the Windows Application Project from the webpage. Is that possible?
    Friday, July 13, 2018 5:17 PM

All replies

  • I have a Windows Applications Project. I created a new Web Application Project under the same solution and I am too call the Program.cs of the Windows Application Project from the webpage. Is that possible?

    No it is not possible in your situation, unless you were using a WCF service being hosted by the Windows program, and with the Web program being a WCF client. 

    The WCF service could then make a call to public method in Program.cs. The WCF solution could be using Named Pipes or TCP/IP if Windows program was not running on the same computer as IIS. 

    On the other hand, why are you trying execute any method on Program.cs?

    Friday, July 13, 2018 7:19 PM
  • An app in your solution is going to produce an EXE. So, like any other EXE, you can run it using the Process class. But for that to work the EXE would either need to be in the same directory as the site or in a searchable path. Also note that by default it'll run as the same account as the app pool which means it probably won't be able to do much.

    Michael Taylor http://www.michaeltaylorp3.net

    Monday, July 16, 2018 2:15 PM
  • My Windows Application actually detects the USB HID using <g class="gr_ gr_54 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="54" id="54">USBLibrary</g>. I want to implement the same on a web page. I can put the application on the server. That is not a problem. But the <g class="gr_ gr_55 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling" data-gr-id="55" id="55">exe</g> has dependent files which don't run if I just call the <g class="gr_ gr_56 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling" data-gr-id="56" id="56">exe</g> file from the web.

    Also when I am calling the Program.cs of the Windows Application from a controller of the web project, I am getting the following error : BadImageFormatException: Could not load file or assembly 'FWUpdater, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. An attempt was made to load a program with an incorrect format.


    Monday, July 16, 2018 2:44 PM
  • The error seems to indicate that you're trying to run (perhaps) an x64 app on an x86 system. Ensure your app is configured for the bitness of the system or set it to Any CPU if it can run as either.

    Note that you aren't going to be able to run an EXE on a web server that can connect to a device on the client machine. Only the browser has access to the client's machine. All the server can do is interact with its own hardware. Trying to run a web app to talk to USB is going to be problematic if this is a regular web app that can have 100s of users at any one time. Are you sure a web app is the correct solution for you?

    Note that you can self host a web app if you're building a management screen for a device (like routers). But as for a regular web app this isn't going to work out well probably.


    Michael Taylor http://www.michaeltaylorp3.net

    Monday, July 16, 2018 2:57 PM
  • I need the data from the device in the webpage. Is there any other way this can be done?
    Monday, July 16, 2018 3:09 PM
  • If the device is on the client (browser) machine then it has to be collected from within the web page. You'll need to post this question in the ASP.NET forums to see if anyone knows of a javascript library that can do that. My initial thought is no unless it is exposed from the OS as a regular device.

    Michael Taylor http://www.michaeltaylorp3.net

    Monday, July 16, 2018 3:41 PM
  • If you need to call an application from a web call , Yes is possible using clickonce.

    using clickonce you can publish your application to an url. 

    from your web page you click on the link and the application will be execute on the client machine

    is it that what you want?.

    gio

    Monday, July 16, 2018 4:50 PM
  • Yes. That works actually. How will I be able to do that? Is there any tutorial link?
    Monday, July 16, 2018 5:49 PM
  • Bear in mind that with ClickOnce you are actually installing an app onto the user's machine. They must agree to this (and network policies must allow it) and you are responsible for keeping the app up to date. Also be aware that many browsers either don't work with the URL directly or require a plugin (FireFox, Chrome) because you're effectively trying to run an EXE (to install the app) from a browser click. At least this is how it worked just a couple of years ago, I haven't tracked the tech since.

    There would also be no interaction between your web app and the app that is installed. This isn't an ActiveX setup. If you're going to that much trouble then why not just wrap your winforms app in a setup program and distribute it directly. It accomplishes basically the same thing.


    Michael Taylor http://www.michaeltaylorp3.net

    Monday, July 16, 2018 6:08 PM
  • The win app program works with usb HID to detect my microchip. I don't think its possible to detect a hid directly through a web page.
    Monday, July 16, 2018 6:21 PM
  • yes there are many tutorial online to publish via clickonce. 

    you can update the app as much as you want, once they start the app, they will get automatically the update. If the app is not connected to internet it will just run as it is. So it runs in local machine of your user without using server cpu.Which is good. 

    just search on google with a right keyword. clickonce application tutorial and chose the right tutorial for your knowledge.

    gio


    • Edited by GDARIE Tuesday, July 17, 2018 4:13 PM
    Tuesday, July 17, 2018 4:08 PM
  • with click once you don't need a plug in like with silverlight. because it suppose to have the framework already. In clickonce you can create a setup with installation requirement which will be silently installed on the client machine. clickonce its a very powerful deployment system.

    gio

    • Edited by GDARIE Tuesday, July 17, 2018 4:16 PM
    Tuesday, July 17, 2018 4:16 PM
  • I would say create a web service that read the hid device and the app that you publish with clickonce make a call on the webservice to retrieve the HID data.

    how does it sound?

    gio

    • Edited by GDARIE Tuesday, July 17, 2018 4:22 PM
    Tuesday, July 17, 2018 4:20 PM