Vince -

Sounds like you are right on the money. Any managed dll coming from the
internet is going to only run under partial trust.

Here is a great article on msdn that explains why this is and how to work
around it for your web apps. The security stuff is the latter part of the
article.

http://msdn.microsoft.com/msdnmag/issues/02/01/UserCtrl/default.aspx

Julie Lerman


-----Original Message-----
From: Unmoderated discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Vince Sanzone
Sent: Thursday, October 07, 2004 7:59 AM
To: [EMAIL PROTECTED]
Subject: [ADVANCED-DOTNET] Winform in Web browser

I am trying to implement a simple webform on a htm/aspx page and I am having
some difficulty. I have searched through many messages on these boards and
found a lot of references to this very thing, but I am still unable to get
it working correctly.

The result I get is the web page finding the dll but not being able to load
it, I get a frame where the control should be with that little icon with the
red square, green circle, and blue triangle.

My UserControl looks like this.

using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

public class FileManager : System.Windows.Forms.UserControl {  private
System.Windows.Forms.Label label1;  private System.ComponentModel.Container
components = null;

 public string TestMethod()
 {
  return "check check";
 }

 public FileManager()
 {
  InitializeComponent();
 }

 protected override void Dispose( bool disposing )  {
  if( disposing )
  {
   if( components != null )
    components.Dispose();
  }
  base.Dispose( disposing );
 }

 #region Component Designer generated code  private void
InitializeComponent()  {
  this.label1 = new System.Windows.Forms.Label();
  this.SuspendLayout();
  //
  // label1
  //
  this.label1.Location = new System.Drawing.Point(64, 40);
  this.label1.Name = "label1";
  this.label1.Size = new System.Drawing.Size(208, 120);
  this.label1.TabIndex = 0;
  this.label1.Text = "label1";
  //
  // FileManager
  //
  this.Controls.Add(this.label1);
  this.Name = "FileManager";
  this.Size = new System.Drawing.Size(336, 200);
  this.ResumeLayout(false);

 }
 #endregion

}


And my htm page looks like this

<html>
<head>
<title></title>
</head>
<body onload="fnLoad()">
<form id="hotform" name="hotform">

<object id="FileManager" classid="FileManager.dll#FileManager" width="100"
height="100" VIEWASTEXT>Not working</object>

<script language="javascript">
function fnLoad() {
 window.alert(document.hotform.FileManager);
 window.alert("before");
 var hotString = document.hotform.FileManager.TestMethod();
 window.alert(hotString);
 window.alert("after");
}
</script>

</form>
</body>
</html>

As far as I can tell I am doing everything programmatically correct. Maybe
there are some security settings that I am missing that are not allowing the
control to load in the browser?

Any help would be much appreciated.

Vince

===================================
This list is hosted by DevelopMentorR  http://www.develop.com Some .NET
courses you may be interested in:

Essential .NET: building applications and components with CSharp August 30 -
September 3, in Los Angeles http://www.develop.com/courses/edotnet

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
Some .NET courses you may be interested in:

Essential .NET: building applications and components with CSharp
August 30 - September 3, in Los Angeles
http://www.develop.com/courses/edotnet

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to