Run existing vb.net functions from simple asp.net page

Discussion in 'ASP .Net Web Services' started by ben, Jan 7, 2004.

  1. ben

    ben Guest

    All,

    What I have:
    I have written a VB.net application that uses Access DBs
    and Make 100s of Excel documents from the data.

    What I need:
    I need a Simple ASP.NET Page that will basically pass a
    string into a function of the Existing Windows
    Application. The app does not run all the time so when
    the user opens the ASP.NET page types in a string and
    clicks the button it calls a function of the existing
    application. I do not have the time or knowledge to
    convert all the functions into ASP code. I am assuming
    there is a simple way to have the ASP.NET standby while
    my app runs its functions.

    What I have done:
    I have made a simple asp.net page and I can pass strings
    into ASP.Net functions just fine. Next I added the vb
    module from my windows app into the ASP.NET project. Now
    I pointed the ASP button at the main function in the vb
    module. I goes through parts of the code until it trys
    to open COM objects (Access 10 library).

    Questions:
    1) am I suppose to add special code to have these
    functions run in an offline mode.
    2) What is this process offically called? So I can
    research this on my own if needs be.

    3)HOW DO I GET AN ASP.NET PAGE TO RUN A FULLY FUNCTIONAL
    VB.NET APPLICATION!!

    Thanks so much,
    Ben
    ben, Jan 7, 2004
    #1
    1. Advertising

  2. Ben,

    > 3)HOW DO I GET AN ASP.NET PAGE TO RUN A FULLY FUNCTIONAL
    > VB.NET APPLICATION!!
    >


    Normally, you don't!. For many reasons this is generally a bad idea.
    Example: ASP.NET is multi-threaded and your app may not be. ASP.NET running
    on a server (like WS2003) may not have permissions to open a window and
    actually run. The GUI app may assume some things about security (eg the
    logged in user may be assumed to have rights; while the ASPNET user does not
    have the same rights (on databases and filesystem etc)). Error handling in
    the GUI app may require user intervention, while a webservice cannot do
    that. And many other reasons.

    Not saying it is not possible, just that it is not an optimal architectural
    approach. If you have all of the VB.NET code, then what I would suggest is
    to package the app into multiple distinct assemblies. Put the business
    logic - the bit that creates the Excel files (or whatever it does) - into
    one assembly, and put the Windows Forms logic - the part that grabs user
    input and paints the screen with pretty pictures - into a separate assembly.
    The business logic DLL would be used from both WinForms app and WebForms
    app. The WinForms DLL would be used only from the GUI app. likewise the
    WebForms logic (aspx files) would be used only from the webforms app.

    If this is not possible, then you can launch a process from within ASP.NET.
    For example,
    private string RunProcess(string cmd) {
    System.Diagnostics.Process p;
    p= new System.Diagnostics.Process();
    p.StartInfo.FileName= cmd;
    p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
    p.StartInfo.RedirectStandardOutput = true;
    p.StartInfo.UseShellExecute = false;
    p.Start();
    // must have the readToEnd BEFORE the WaitForExit(), to avoid a deadlock
    condition
    string output= p.StandardOutput.ReadToEnd();
    p.WaitForExit();
    return output;
    }

    But as I said, there are lots and lots of reasons not to use this approach.
    -Dino



    > Thanks so much,
    > Ben
    > ben_oates@something something.com


    ooooh, I wouldn't do that if I were you. Posting your email address in
    plain text is just asking for spam . .
    Dino Chiesa [Microsoft], Jan 8, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ben
    Replies:
    2
    Views:
    734
    Kevin Spencer
    Jan 7, 2004
  2. Replies:
    0
    Views:
    616
  3. nrm
    Replies:
    3
    Views:
    517
  4. Xiangliang Meng
    Replies:
    1
    Views:
    1,577
    Victor Bazarov
    Jun 21, 2004
  5. Replies:
    0
    Views:
    176
Loading...

Share This Page