Embedding WinForms in WebForms ?

A

Andrew

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:

http://samples.gotdotnet.com/quickstart/winforms/doc/WinFormsIeSourcing.aspx
http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=187&printer=t

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
problems...

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top