windowsforms application won't load from .aspx file

L

Loane Sharp

Hi there

I have a Windows Forms application that contacts the server and retrieves
particular files, if they exist. To the best of my knowledge, the .exe
assembly is properly compiled, strongly named, etc.

Specifically, within Control Panel>Administrative Tools>Microsoft .NET
Framework 2.0 Configuration>Assembly Cache, I have added myApp.exe to the
global assembly cache. Also, within >Microsoft .NET Framework 2.0
Wizards>Trust an assembly>Make changes to this computer ... I have set the
trust level for myApp.exe to "full trust".

However I'm having real trouble running the .exe from within my .aspx file.
The page loads for a very long time without returning anything. I'm
supposing there's a security violation, since the .exe runs perfectly well
outside the web page, on double-clicking.

Excerpts of my .aspx file code are given below.

Please help!

Best regards
Loane


<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Configuration.ConfigurationSettings" %>
<%@ Import Namespace="System.Reflection" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.Security" %>
<%@ Import Namespace="System.Security.Policy" %>
<%@ Import Namespace="System.Security.Permissions" %>
<%@ OutputCache Location="None" VaryByParam="None" %>
....
<HEAD>
<SCRIPT LANGUAGE="VB" RUNAT="SERVER">

Protected Sub Page_Load( )

Try

' Set up the AppDomain
Dim setup As New AppDomainSetup()
setup.ApplicationBase = "c:\inetpub\wwwroot\"
setup.ConfigurationFile = "web.config"

' Set up the Evidence
Dim baseEvidence As Evidence = AppDomain.CurrentDomain.Evidence
Dim evidence As New Evidence(baseEvidence)
evidence.AddAssembly("c:\inetpub\wwwroot\myApp.exe")
evidence.AddHost("localhost")

' Create the AppDomain
Dim newDomain As AppDomain = AppDomain.CreateDomain("newDomain", evidence,
setup)
newDomain.ExecuteAssembly("c:\inetpub\wwwroot\myApp.exe")

Catch ex As Exception
Response.Write("Exception occurred.")
End Try

End Sub

</SCRIPT>
</HEAD>
....
 
S

Scott Allen

Hi Loane:

What evidence are you using to trust the executable? A publisher's key
or URL evidence?

Installing the app into the GAC probably won't help, as when launching
from the web the app will be coming from a different 'zone'.
 

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

Top