AppDomain::ExecuteAssembly Method (String, Evidence)
Note: This API is now obsolete. The non-obsolete alternative is ExecuteAssembly(String).
Executes the assembly contained in the specified file, using the specified evidence.
Assembly: mscorlib (in mscorlib.dll)
[ObsoleteAttribute(L"Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of ExecuteAssembly which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")] public: virtual int ExecuteAssembly( String^ assemblyFile, Evidence^ assemblySecurity ) sealed
Parameters
- assemblyFile
- Type: System::String
The name of the file that contains the assembly to execute.
- assemblySecurity
- Type: System.Security.Policy::Evidence
Evidence for loading the assembly.
Implements
_AppDomain::ExecuteAssembly(String, Evidence)| Exception | Condition |
|---|---|
| ArgumentNullException | assemblyFile is nullptr. |
| FileNotFoundException | assemblyFile is not found. |
| BadImageFormatException | assemblyFile is not a valid assembly. -or- Version 2.0 or later of the common language runtime is currently loaded and assemblyFile was compiled with a later version. |
| AppDomainUnloadedException | The operation is attempted on an unloaded application domain. |
| FileLoadException | An assembly or module was loaded twice with two different evidences. |
| MissingMethodException | The specified assembly has no entry point. |
The assembly begins executing at the entry point specified in the .NET Framework header.
The ExecuteAssembly method does not create a new process or application domain, and it does not execute the entry point method on a new thread.
This method loads assemblies using the LoadFile method. You can also execute assemblies using the ExecuteAssemblyByName method, which loads assemblies using the Load method.
The following sample demonstrates using one of the overloads of ExecuteAssembly on two different domains.
int main() { AppDomain^ currentDomain = AppDomain::CurrentDomain; AppDomain^ otherDomain = AppDomain::CreateDomain( "otherDomain" ); currentDomain->ExecuteAssembly( "MyExecutable.exe" ); // Prints S"MyExecutable running on [default]" otherDomain->ExecuteAssembly( "MyExecutable.exe" ); // Prints S"MyExecutable running on otherDomain" }
- SecurityPermission
to load an assembly with evidence. Associated enumeration: SecurityPermissionFlag::ControlEvidence.
- FileIOPermission
for access to read from a file or directory, and for access to the information in the path itself. Associated enumerations: FileIOPermissionAccess::Read, FileIOPermissionAccess::PathDiscovery.
- WebPermission
for reading a URI that does not begin with "file://".
- UIPermission
to execute a console application. Associated enumeration: PermissionState::Unrestricted.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.