This commit is contained in:
31
source/csla10/NetRun/AssemblyInfo.vb
Normal file
31
source/csla10/NetRun/AssemblyInfo.vb
Normal file
@@ -0,0 +1,31 @@
|
||||
Imports System.Reflection
|
||||
Imports System.Runtime.InteropServices
|
||||
|
||||
' General Information about an assembly is controlled through the following
|
||||
' set of attributes. Change these attribute values to modify the information
|
||||
' associated with an assembly.
|
||||
|
||||
' Review the values of the assembly attributes
|
||||
|
||||
<Assembly: AssemblyTitle("NetRun")>
|
||||
<Assembly: AssemblyDescription("No-touch deployment utility")>
|
||||
<Assembly: AssemblyCompany("Rockford Lhotka")>
|
||||
<Assembly: AssemblyProduct("NetRun")>
|
||||
<Assembly: AssemblyCopyright("Copyright 2003 Rockford Lhotka. All rights reserved.")>
|
||||
<Assembly: AssemblyTrademark("")>
|
||||
<Assembly: CLSCompliant(True)>
|
||||
|
||||
'The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
<Assembly: Guid("65567A5E-28FC-48E1-B027-F79552E755A9")>
|
||||
|
||||
' Version information for an assembly consists of the following four values:
|
||||
'
|
||||
' Major Version
|
||||
' Minor Version
|
||||
' Build Number
|
||||
' Revision
|
||||
'
|
||||
' You can specify all the values or you can default the Build and Revision Numbers
|
||||
' by using the '*' as shown below:
|
||||
|
||||
<Assembly: AssemblyVersion("1.3.*")>
|
||||
174
source/csla10/NetRun/Launcher.vb
Normal file
174
source/csla10/NetRun/Launcher.vb
Normal file
@@ -0,0 +1,174 @@
|
||||
Imports System.Reflection
|
||||
Imports System.Security
|
||||
Imports System.Security.Policy
|
||||
Imports System.Security.Permissions
|
||||
|
||||
Public Class Launcher
|
||||
Inherits MarshalByRefObject
|
||||
|
||||
Private mAppURL As String
|
||||
Private mAppDir As String
|
||||
Private mAppName As String
|
||||
|
||||
Private mGroupExisted As Boolean
|
||||
|
||||
Public Sub RunApp(ByVal AppURL As String)
|
||||
|
||||
' before we do anything, invoke the workaround
|
||||
' for the serialization bug
|
||||
SerializationWorkaround()
|
||||
|
||||
Try
|
||||
' get and parse the URL for the app we are
|
||||
' launching
|
||||
mAppURL = AppURL
|
||||
mAppDir = GetAppDirectory(mAppURL)
|
||||
mAppName = GetAppName(mAppURL)
|
||||
|
||||
' TODO: MAKE SURE TO TIGHTEN SECURITY BEFORE USING!!!!
|
||||
' see http://www.lhotka.net/Articles.aspx?id=2f5a8115-b425-4aa1-bae2-b8f80766ecb3
|
||||
SetSecurity()
|
||||
|
||||
' load the assembly into our AppDomain
|
||||
Dim asm As [Assembly]
|
||||
asm = [Assembly].LoadFrom(AppURL)
|
||||
|
||||
' run the program by invoking its entry point
|
||||
asm.EntryPoint.Invoke(asm.EntryPoint, Nothing)
|
||||
|
||||
Finally
|
||||
RemoveSecurity()
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
|
||||
#Region " Serialization bug workaround "
|
||||
|
||||
Private Sub SerializationWorkaround()
|
||||
|
||||
' hook up the AssemblyResolve
|
||||
' event so deep serialization works properly
|
||||
' this is a workaround for a bug in the .NET runtime
|
||||
Dim currentDomain As AppDomain = AppDomain.CurrentDomain
|
||||
|
||||
AddHandler currentDomain.AssemblyResolve, _
|
||||
AddressOf ResolveEventHandler
|
||||
|
||||
End Sub
|
||||
|
||||
Private Function ResolveEventHandler(ByVal sender As Object, ByVal args As ResolveEventArgs) As [Assembly]
|
||||
|
||||
' get a list of all the assemblies loaded in our appdomain
|
||||
Dim list() As [Assembly] = AppDomain.CurrentDomain.GetAssemblies()
|
||||
|
||||
' search the list to find the assemby that was not found automatically
|
||||
' and return the assembly from the list
|
||||
Dim asm As [Assembly]
|
||||
|
||||
For Each asm In list
|
||||
If asm.FullName = args.Name Then
|
||||
Return asm
|
||||
End If
|
||||
Next
|
||||
|
||||
End Function
|
||||
|
||||
#End Region
|
||||
|
||||
#Region " SetSecurity to FullTrust "
|
||||
|
||||
Private Sub SetSecurity()
|
||||
|
||||
Dim ph As System.Collections.IEnumerator
|
||||
Dim pl As System.Security.Policy.PolicyLevel
|
||||
Dim found As Boolean
|
||||
|
||||
' retrieve the security policy hierarchy
|
||||
ph = SecurityManager.PolicyHierarchy
|
||||
|
||||
' loop through to find the Machine level sub-tree
|
||||
Do While ph.MoveNext
|
||||
pl = CType(ph.Current, PolicyLevel)
|
||||
If pl.Label = "Machine" Then
|
||||
found = True
|
||||
Exit Do
|
||||
End If
|
||||
Loop
|
||||
|
||||
If found Then
|
||||
' see if the codegroup for this app already exists
|
||||
' as a machine-level entry
|
||||
Dim cg As CodeGroup
|
||||
For Each cg In pl.RootCodeGroup.Children
|
||||
If cg.Name = mAppName Then
|
||||
' codegroup already exists
|
||||
' we assume it is set to a valid
|
||||
' permission level
|
||||
mGroupExisted = True
|
||||
Exit Sub
|
||||
End If
|
||||
Next
|
||||
|
||||
' the codegroup doesn't already exist, so
|
||||
' we'll add a url group with FullTrust
|
||||
mGroupExisted = False
|
||||
Dim ucg As UnionCodeGroup = _
|
||||
New UnionCodeGroup(New UrlMembershipCondition(mAppDir & "/*"), _
|
||||
New PolicyStatement(New NamedPermissionSet("FullTrust")))
|
||||
ucg.Description = "Temporary entry for " & mAppURL
|
||||
ucg.Name = mAppName
|
||||
pl.RootCodeGroup.AddChild(ucg)
|
||||
SecurityManager.SavePolicy()
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
#Region " RemoveSecurity "
|
||||
|
||||
Private Sub RemoveSecurity()
|
||||
|
||||
' if the group existed before NetRun was used
|
||||
' we want to leave the group intact, so we
|
||||
' can just exit
|
||||
If mGroupExisted Then Exit Sub
|
||||
|
||||
' on the other hand, if the group didn't already
|
||||
' exist then we need to remove it now that
|
||||
' the business application is closed
|
||||
Dim ph As System.Collections.IEnumerator
|
||||
Dim pl As System.Security.Policy.PolicyLevel
|
||||
Dim found As Boolean
|
||||
|
||||
' retrieve the security policy hierarchy
|
||||
ph = SecurityManager.PolicyHierarchy
|
||||
|
||||
' loop through to find the Machine level sub-tree
|
||||
Do While ph.MoveNext
|
||||
pl = CType(ph.Current, PolicyLevel)
|
||||
If pl.Label = "Machine" Then
|
||||
found = True
|
||||
Exit Do
|
||||
End If
|
||||
Loop
|
||||
|
||||
If found Then
|
||||
' see if the codegroup for this app exists
|
||||
' as a machine-level entry
|
||||
Dim cg As CodeGroup
|
||||
For Each cg In pl.RootCodeGroup.Children
|
||||
If cg.Name = mAppName Then
|
||||
' codegroup exits - remove it
|
||||
pl.RootCodeGroup.RemoveChild(cg)
|
||||
SecurityManager.SavePolicy()
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
End Class
|
||||
114
source/csla10/NetRun/Main.vb
Normal file
114
source/csla10/NetRun/Main.vb
Normal file
@@ -0,0 +1,114 @@
|
||||
Imports System.IO
|
||||
Imports System.Reflection
|
||||
Imports System.Security
|
||||
Imports System.Security.Policy
|
||||
Imports System.Security.Permissions
|
||||
|
||||
Module Main
|
||||
|
||||
Public Sub Main()
|
||||
|
||||
Try
|
||||
' launch the app based on the URL provided by the user
|
||||
RunAppliation(Microsoft.VisualBasic.Command)
|
||||
|
||||
Catch ex As Exception
|
||||
Dim sb As New System.Text.StringBuilder()
|
||||
sb.Append("NetRun was unable to launch the application")
|
||||
sb.Append(vbCrLf)
|
||||
sb.Append(Microsoft.VisualBasic.Command)
|
||||
sb.Append(vbCrLf)
|
||||
sb.Append(vbCrLf)
|
||||
sb.Append(ex.ToString)
|
||||
MsgBox(sb.ToString, MsgBoxStyle.Exclamation)
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
|
||||
#Region " RunApplication "
|
||||
|
||||
Private Sub RunAppliation(ByVal AppURL As String)
|
||||
|
||||
' create setup object for the new app domain
|
||||
Dim setupDomain As New AppDomainSetup()
|
||||
With setupDomain
|
||||
' give it a valid base path
|
||||
.ApplicationBase = CurrentDomainPath()
|
||||
' give it a safe config file name
|
||||
.ConfigurationFile = AppURL + ".remoteconfig"
|
||||
End With
|
||||
|
||||
' create new application domain
|
||||
Dim newDomain As AppDomain = _
|
||||
AppDomain.CreateDomain( _
|
||||
GetAppName(AppURL), Nothing, setupDomain)
|
||||
|
||||
' create launcher object in new appdomain
|
||||
Dim launcher As Launcher = _
|
||||
CType(newDomain.CreateInstanceAndUnwrap( _
|
||||
"NetRun", "NetRun.Launcher"), _
|
||||
Launcher)
|
||||
|
||||
' use launcher object from the new domain
|
||||
' to launch the remote app in that appdomain
|
||||
launcher.RunApp(AppURL)
|
||||
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
#Region " GetCurrentDomainPath "
|
||||
|
||||
Private Function CurrentDomainPath() As String
|
||||
|
||||
' get path of current assembly
|
||||
Dim currentPath As String = [Assembly].GetExecutingAssembly.CodeBase
|
||||
' convert it to a URI for ease of use
|
||||
Dim currentURI As Uri = New Uri(currentPath)
|
||||
' get the path portion of the URI
|
||||
Dim currentLocalPath As String = currentURI.LocalPath
|
||||
|
||||
' return the full name of the path
|
||||
Return New DirectoryInfo(currentLocalPath).Parent.FullName
|
||||
|
||||
End Function
|
||||
|
||||
#End Region
|
||||
|
||||
#Region " URL parsing functions "
|
||||
|
||||
Public Function GetAppDirectory(ByVal AppURL As String) As String
|
||||
|
||||
' get the path without prog name
|
||||
Dim appURI As New System.Uri(AppURL)
|
||||
Dim appPath As String = appURI.GetLeftPart(UriPartial.Path)
|
||||
Dim pos As Integer
|
||||
|
||||
For pos = Len(appPath) To 1 Step -1
|
||||
If Mid(appPath, pos, 1) = "/" OrElse Mid(appPath, pos, 1) = "\" Then
|
||||
Return Left(appPath, pos - 1)
|
||||
End If
|
||||
Next
|
||||
Return ""
|
||||
|
||||
End Function
|
||||
|
||||
Public Function GetAppName(ByVal AppURL As String) As String
|
||||
|
||||
' get the prog name without path
|
||||
Dim appURI As New System.Uri(AppURL)
|
||||
Dim appPath As String = appURI.GetLeftPart(UriPartial.Path)
|
||||
Dim pos As Integer
|
||||
|
||||
For pos = Len(appPath) To 1 Step -1
|
||||
If Mid(appPath, pos, 1) = "/" OrElse Mid(appPath, pos, 1) = "\" Then
|
||||
Return Mid(appPath, pos + 1)
|
||||
End If
|
||||
Next
|
||||
Return ""
|
||||
|
||||
End Function
|
||||
|
||||
#End Region
|
||||
|
||||
End Module
|
||||
121
source/csla10/NetRun/NetRun.vbproj
Normal file
121
source/csla10/NetRun/NetRun.vbproj
Normal file
@@ -0,0 +1,121 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectType>Local</ProjectType>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{24FFD3D5-D449-403F-88F3-04D9E17422A6}</ProjectGuid>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ApplicationIcon>
|
||||
</ApplicationIcon>
|
||||
<AssemblyKeyContainerName>
|
||||
</AssemblyKeyContainerName>
|
||||
<AssemblyName>NetRun</AssemblyName>
|
||||
<AssemblyOriginatorKeyFile>
|
||||
</AssemblyOriginatorKeyFile>
|
||||
<AssemblyOriginatorKeyMode>None</AssemblyOriginatorKeyMode>
|
||||
<DefaultClientScript>JScript</DefaultClientScript>
|
||||
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
|
||||
<DefaultTargetSchema>IE50</DefaultTargetSchema>
|
||||
<DelaySign>false</DelaySign>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<OptionCompare>Binary</OptionCompare>
|
||||
<OptionExplicit>On</OptionExplicit>
|
||||
<OptionStrict>Off</OptionStrict>
|
||||
<RootNamespace>NetRun</RootNamespace>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<MyType>WindowsFormsWithCustomSubMain</MyType>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DocumentationFile>NetRun.xml</DocumentationFile>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
<DefineConstants>
|
||||
</DefineConstants>
|
||||
<DefineDebug>true</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<Optimize>false</Optimize>
|
||||
<RegisterForComInterop>false</RegisterForComInterop>
|
||||
<RemoveIntegerChecks>false</RemoveIntegerChecks>
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<WarningLevel>1</WarningLevel>
|
||||
<NoWarn>42016,42017,42018,42019,42032</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DocumentationFile>NetRun.xml</DocumentationFile>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
<DefineConstants>
|
||||
</DefineConstants>
|
||||
<DefineDebug>false</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
<Optimize>true</Optimize>
|
||||
<RegisterForComInterop>false</RegisterForComInterop>
|
||||
<RemoveIntegerChecks>false</RemoveIntegerChecks>
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<WarningLevel>1</WarningLevel>
|
||||
<NoWarn>42016,42017,42018,42019,42032</NoWarn>
|
||||
<DebugType>none</DebugType>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<Name>System</Name>
|
||||
</Reference>
|
||||
<Reference Include="System.Data">
|
||||
<Name>System.Data</Name>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing">
|
||||
<Name>System.Drawing</Name>
|
||||
</Reference>
|
||||
<Reference Include="System.Windows.Forms">
|
||||
<Name>System.Windows.Forms</Name>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml">
|
||||
<Name>System.XML</Name>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Import Include="Microsoft.VisualBasic" />
|
||||
<Import Include="System" />
|
||||
<Import Include="System.Collections" />
|
||||
<Import Include="System.Data" />
|
||||
<Import Include="System.Diagnostics" />
|
||||
<Import Include="System.Drawing" />
|
||||
<Import Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyInfo.vb">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Launcher.vb">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Main.vb">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<UserProperties GenerateXMLDocForProject="FALSE" />
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
58
source/csla10/NetRun/NetRun.vbproj.user
Normal file
58
source/csla10/NetRun/NetRun.vbproj.user
Normal file
@@ -0,0 +1,58 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<LastOpenVersion>7.10.3077</LastOpenVersion>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ReferencePath>
|
||||
</ReferencePath>
|
||||
<CopyProjectDestinationFolder>
|
||||
</CopyProjectDestinationFolder>
|
||||
<CopyProjectUncPath>
|
||||
</CopyProjectUncPath>
|
||||
<CopyProjectOption>0</CopyProjectOption>
|
||||
<ProjectView>ProjectFiles</ProjectView>
|
||||
<ProjectTrust>0</ProjectTrust>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<EnableASPDebugging>false</EnableASPDebugging>
|
||||
<EnableASPXDebugging>false</EnableASPXDebugging>
|
||||
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||
<EnableSQLServerDebugging>false</EnableSQLServerDebugging>
|
||||
<RemoteDebugEnabled>false</RemoteDebugEnabled>
|
||||
<RemoteDebugMachine>
|
||||
</RemoteDebugMachine>
|
||||
<StartAction>Project</StartAction>
|
||||
<StartArguments>
|
||||
</StartArguments>
|
||||
<StartPage>
|
||||
</StartPage>
|
||||
<StartProgram>
|
||||
</StartProgram>
|
||||
<StartURL>
|
||||
</StartURL>
|
||||
<StartWorkingDirectory>
|
||||
</StartWorkingDirectory>
|
||||
<StartWithIE>false</StartWithIE>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<EnableASPDebugging>false</EnableASPDebugging>
|
||||
<EnableASPXDebugging>false</EnableASPXDebugging>
|
||||
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||
<EnableSQLServerDebugging>false</EnableSQLServerDebugging>
|
||||
<RemoteDebugEnabled>false</RemoteDebugEnabled>
|
||||
<RemoteDebugMachine>
|
||||
</RemoteDebugMachine>
|
||||
<StartAction>Project</StartAction>
|
||||
<StartArguments>
|
||||
</StartArguments>
|
||||
<StartPage>
|
||||
</StartPage>
|
||||
<StartProgram>
|
||||
</StartProgram>
|
||||
<StartURL>
|
||||
</StartURL>
|
||||
<StartWorkingDirectory>
|
||||
</StartWorkingDirectory>
|
||||
<StartWithIE>false</StartWithIE>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
BIN
source/csla10/NetRun/bin/NetRun.exe
Normal file
BIN
source/csla10/NetRun/bin/NetRun.exe
Normal file
Binary file not shown.
11
source/csla10/NetRun/bin/NetRun.xml
Normal file
11
source/csla10/NetRun/bin/NetRun.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>
|
||||
NetRun
|
||||
</name>
|
||||
</assembly>
|
||||
<members>
|
||||
|
||||
</members>
|
||||
</doc>
|
||||
5
source/csla10/NetRun/obj/NetRun.vbproj.FileList.txt
Normal file
5
source/csla10/NetRun/obj/NetRun.vbproj.FileList.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
bin\NetRun.exe
|
||||
bin\NetRun.xml
|
||||
obj\Release\ResolveAssemblyReference.cache
|
||||
obj\Release\NetRun.exe
|
||||
obj\Release\NetRun.xml
|
||||
BIN
source/csla10/NetRun/obj/Release/NetRun.exe
Normal file
BIN
source/csla10/NetRun/obj/Release/NetRun.exe
Normal file
Binary file not shown.
11
source/csla10/NetRun/obj/Release/NetRun.xml
Normal file
11
source/csla10/NetRun/obj/Release/NetRun.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>
|
||||
NetRun
|
||||
</name>
|
||||
</assembly>
|
||||
<members>
|
||||
|
||||
</members>
|
||||
</doc>
|
||||
Reference in New Issue
Block a user