Embedding WinForms in WebForms ?

Discussion in 'ASP .Net Web Controls' started by Andrew, Jun 3, 2004.

  1. Andrew

    Andrew Guest

    Hi all,

    I am coming from the ASP Classic and VB6 world. Getting into .net, but
    still relatively new. I am beginning to hear rumblings from on high that we
    will be transitioning our website from ASP to ASP.net. However, on our
    Intranet side (which will undoubtedly be converted also) we have several
    ActiveX Controls. These controls were all created here -- no third party
    controls that is. The controls serv as the means to upload multiple files
    at one time, communicate direct to the DB wihtout causing page refresh,
    allow various data manipulation, etc. The controls were a best case
    alternative in that they were self contained, debug-able, and could be
    "many-in-one" devices. Since these are only used on our Intranet, the
    security was not an issue.

    Now that I see we need to get ready for moving to .net, I have been trying
    to learn the .net way of making similar controls. I have found a couple
    websites that discuss embedding Windows Forms inside Web Forms:


    Yet while these two give some basic information about how the controls need
    to be designed, what goes into them, and so forth....they are very simple --
    making text bold, changing text, etc. I have been able to get these to work
    just fine. It's just....when I try to go a little more extreme, I run into

    I tried to create a simple control that would open a text file -- path
    supplied by typing it in a textbox and clicking the "go" button -- and
    display the text contents in a multiline textbox. Yet when I try to run it,
    I am getting an error:

    System.Security.SecurityException: Request for the permission of type
    System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0,
    Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
    at System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet
    grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
    PermissionToken permToken)
    at System.Security.CodeAccessSecurityEngine.Check(PermissionToken
    permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32
    checkFrames, Int32 unrestrictedOverride)
    at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission
    cap, StackCrawlMark& stackMark)
    at System.Security.CodeAccessPermission.Demand()
    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
    access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath,
    Boolean bFromProxy)
    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
    access, FileShare share, Int32 bufferSize)
    at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean
    detectEncodingFromByteOrderMarks, Int32 bufferSize)
    at System.IO.StreamReader..ctor(String path)
    at ReadFile.ReadFile.cmdReadFile_Click(Object sender, EventArgs e)
    at System.Windows.Forms.Control.OnClick(EventArgs e)
    at System.Windows.Forms.Button.OnClick(EventArgs e)
    at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
    button, Int32 clicks)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ButtonBase.WndProc(Message& m)
    at System.Windows.Forms.Button.WndProc(Message& m)
    at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
    IntPtr wparam, IntPtr lparam)

    I have tried setting security to low for the file, folder, IIS,
    everything....I have used the MS .Net Security Policy Administration Wizard
    to lower security...I just don't know what else I need to do to get this to
    run correctly.

    Could someone help me understand what I need to do in order to get WinForms
    embedded in WebForms (regardless of the purpose of the code used in the
    WinForm) to function without errors?

    Your help/input greatly appreciated.

    -- Andrew
    Andrew, Jun 3, 2004
    1. Advertisements

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. John Sparrow
    Jun 26, 2003
  2. PsiMan

    Embedding Webforms

    PsiMan, Jul 9, 2003, in forum: ASP .Net
    Steve C. Orr, MCSD
    Jul 9, 2003
  3. Martin Rosén-Lidholm

    Productivity: WebForms vs. WinForms

    Martin Rosén-Lidholm, Jun 21, 2004, in forum: ASP .Net
    Rob Nicholson
    Jul 8, 2004
  4. Phil Winstanley [Microsoft MVP ASP.NET]

    Re: Productivity: WebForms vs. WinForms

    Phil Winstanley [Microsoft MVP ASP.NET], Jun 21, 2004, in forum: ASP .Net
    Phil Winstanley [Microsoft MVP ASP.NET]
    Jun 21, 2004
  5. David Jackson
    David Jackson
    May 7, 2009