2 // System.Reflection/Assembly.cs
5 // Paolo Molaro (lupus@ximian.com)
7 // (C) 2001 Ximian, Inc. http://www.ximian.com
8 // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
9 // Copyright 2011 Xamarin Inc (http://www.xamarin.com).
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System.Security;
32 using System.Security.Policy;
33 using System.Security.Permissions;
34 using System.Runtime.Serialization;
35 using System.Reflection;
37 using System.Globalization;
38 using System.Runtime.CompilerServices;
39 using System.Runtime.InteropServices;
40 using System.Collections.Generic;
41 using System.Configuration.Assemblies;
42 using System.Threading;
44 using System.Diagnostics.Contracts;
48 namespace System.Reflection {
51 [ComDefaultInterfaceAttribute (typeof (_Assembly))]
53 [ClassInterface(ClassInterfaceType.None)]
54 [StructLayout (LayoutKind.Sequential)]
56 public partial class Assembly : ICustomAttributeProvider {
58 public abstract class Assembly : ICustomAttributeProvider, _Assembly, IEvidenceFactory, ISerializable {
60 internal class ResolveEventHolder {
61 public event ModuleResolveEventHandler ModuleResolve;
64 internal class UnmanagedMemoryStreamForModule : UnmanagedMemoryStream
68 public unsafe UnmanagedMemoryStreamForModule (byte* pointer, long length, Module module)
69 : base (pointer, length)
74 protected override void Dispose (bool disposing)
78 * The returned pointer points inside metadata, so
79 * we have to increase the refcount of the module, and decrease
80 * it when the stream is finalized.
85 base.Dispose (disposing);
89 // Note: changes to fields must be reflected in _MonoReflectionAssembly struct (object-internals.h)
90 #pragma warning disable 649
91 private IntPtr _mono_assembly;
92 #pragma warning restore 649
94 private ResolveEventHolder resolve_event_holder;
96 private Evidence _evidence;
97 internal PermissionSet _minimum; // for SecurityAction.RequestMinimum
98 internal PermissionSet _optional; // for SecurityAction.RequestOptional
99 internal PermissionSet _refuse; // for SecurityAction.RequestRefuse
100 private PermissionSet _granted; // for the resolved assembly granted permissions
101 private PermissionSet _denied; // for the resolved assembly denied permissions
103 object _evidence, _minimum, _optional, _refuse, _granted, _denied;
105 private bool fromByteArray;
106 private string assemblyName;
111 resolve_event_holder = new ResolveEventHolder ();
115 // We can't store the event directly in this class, since the
116 // compiler would silently insert the fields before _mono_assembly
118 public event ModuleResolveEventHandler ModuleResolve {
119 [SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
121 resolve_event_holder.ModuleResolve += value;
123 [SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
125 resolve_event_holder.ModuleResolve -= value;
129 [MethodImplAttribute (MethodImplOptions.InternalCall)]
130 private extern string get_code_base (bool escaped);
132 [MethodImplAttribute (MethodImplOptions.InternalCall)]
133 private extern string get_fullname ();
135 [MethodImplAttribute (MethodImplOptions.InternalCall)]
136 private extern string get_location ();
138 [MethodImplAttribute (MethodImplOptions.InternalCall)]
139 private extern string InternalImageRuntimeVersion ();
141 // SECURITY: this should be the only caller to icall get_code_base
142 private string GetCodeBase (bool escaped)
144 string cb = get_code_base (escaped);
146 if (SecurityManager.SecurityEnabled) {
147 // we cannot divulge local file informations
148 if (String.Compare ("FILE://", 0, cb, 0, 7, true, CultureInfo.InvariantCulture) == 0) {
149 string file = cb.Substring (7);
150 new FileIOPermission (FileIOPermissionAccess.PathDiscovery, file).Demand ();
157 public virtual string CodeBase {
158 get { return GetCodeBase (false); }
161 public virtual string EscapedCodeBase {
162 get { return GetCodeBase (true); }
165 public virtual string FullName {
168 // FIXME: This is wrong, but it gets us going
169 // in the compiler for now
175 public virtual extern MethodInfo EntryPoint {
176 [MethodImplAttribute (MethodImplOptions.InternalCall)]
180 public virtual Evidence Evidence {
181 [SecurityPermission (SecurityAction.Demand, ControlEvidence = true)]
182 get { return UnprotectedGetEvidence (); }
185 // note: the security runtime requires evidences but may be unable to do so...
186 internal Evidence UnprotectedGetEvidence ()
191 // if the host (runtime) hasn't provided it's own evidence...
192 if (_evidence == null) {
193 // ... we will provide our own
195 _evidence = Evidence.GetDefaultHostEvidence (this);
202 [MethodImplAttribute (MethodImplOptions.InternalCall)]
203 internal extern bool get_global_assembly_cache ();
205 internal bool FromByteArray {
206 set { fromByteArray = value; }
209 public virtual String Location {
214 string loc = get_location ();
216 if ((loc != String.Empty) && SecurityManager.SecurityEnabled) {
217 // we cannot divulge local file informations
218 new FileIOPermission (FileIOPermissionAccess.PathDiscovery, loc).Demand ();
226 public virtual string ImageRuntimeVersion {
228 return InternalImageRuntimeVersion ();
232 public virtual void GetObjectData (SerializationInfo info, StreamingContext context)
234 throw new NotImplementedException ();
237 public virtual bool IsDefined (Type attributeType, bool inherit)
239 return MonoCustomAttrs.IsDefined (this, attributeType, inherit);
242 public virtual object [] GetCustomAttributes (bool inherit)
244 return MonoCustomAttrs.GetCustomAttributes (this, inherit);
247 public virtual object [] GetCustomAttributes (Type attributeType, bool inherit)
249 return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
252 [MethodImplAttribute (MethodImplOptions.InternalCall)]
253 private extern object GetFilesInternal (String name, bool getResourceModules);
255 public virtual FileStream[] GetFiles ()
257 return GetFiles (false);
260 public virtual FileStream [] GetFiles (bool getResourceModules)
262 string[] names = (string[]) GetFilesInternal (null, getResourceModules);
264 return EmptyArray<FileStream>.Value;
266 string location = Location;
269 if (location != String.Empty) {
270 res = new FileStream [names.Length + 1];
271 res [0] = new FileStream (location, FileMode.Open, FileAccess.Read);
272 for (int i = 0; i < names.Length; ++i)
273 res [i + 1] = new FileStream (names [i], FileMode.Open, FileAccess.Read);
275 res = new FileStream [names.Length];
276 for (int i = 0; i < names.Length; ++i)
277 res [i] = new FileStream (names [i], FileMode.Open, FileAccess.Read);
282 public virtual FileStream GetFile (String name)
285 throw new ArgumentNullException (null, "Name cannot be null.");
286 if (name.Length == 0)
287 throw new ArgumentException ("Empty name is not valid");
289 string filename = (string)GetFilesInternal (name, true);
290 if (filename != null)
291 return new FileStream (filename, FileMode.Open, FileAccess.Read);
296 [MethodImplAttribute (MethodImplOptions.InternalCall)]
297 internal extern IntPtr GetManifestResourceInternal (String name, out int size, out Module module);
299 public virtual Stream GetManifestResourceStream (String name)
302 throw new ArgumentNullException ("name");
303 if (name.Length == 0)
304 throw new ArgumentException ("String cannot have zero length.",
307 ManifestResourceInfo info = GetManifestResourceInfo (name);
309 Assembly a = AppDomain.CurrentDomain.DoResourceResolve (name, this);
310 if (a != null && a != this)
311 return a.GetManifestResourceStream (name);
316 if (info.ReferencedAssembly != null)
317 return info.ReferencedAssembly.GetManifestResourceStream (name);
318 if ((info.FileName != null) && (info.ResourceLocation == 0)) {
320 throw new FileNotFoundException (info.FileName);
322 string location = Path.GetDirectoryName (Location);
323 string filename = Path.Combine (location, info.FileName);
324 return new FileStream (filename, FileMode.Open, FileAccess.Read);
329 IntPtr data = GetManifestResourceInternal (name, out size, out module);
330 if (data == (IntPtr) 0)
333 UnmanagedMemoryStream stream;
335 stream = new UnmanagedMemoryStreamForModule ((byte*) data, size, module);
341 public virtual Stream GetManifestResourceStream (Type type, String name)
343 StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
344 return GetManifestResourceStream(type, name, false, ref stackMark);
347 internal Stream GetManifestResourceStream (Type type, String name, bool skipSecurityCheck, ref StackCrawlMark stackMark)
349 StringBuilder sb = new StringBuilder ();
352 throw new ArgumentNullException ("type");
354 String nameSpace = type.Namespace;
355 if (nameSpace != null) {
356 sb.Append (nameSpace);
358 sb.Append (Type.Delimiter);
365 return GetManifestResourceStream (sb.ToString());
368 internal unsafe Stream GetManifestResourceStream(String name, ref StackCrawlMark stackMark, bool skipSecurityCheck)
370 return GetManifestResourceStream (null, name, skipSecurityCheck, ref stackMark);
373 internal String GetSimpleName()
375 AssemblyName aname = GetName (true);
379 internal byte[] GetPublicKey()
381 AssemblyName aname = GetName (true);
382 return aname.GetPublicKey ();
385 internal Version GetVersion()
387 AssemblyName aname = GetName (true);
388 return aname.Version;
391 private AssemblyNameFlags GetFlags()
393 AssemblyName aname = GetName (true);
397 [MethodImplAttribute (MethodImplOptions.InternalCall)]
398 internal virtual extern Type[] GetTypes (bool exportedOnly);
400 public virtual Type[] GetTypes ()
402 return GetTypes (false);
405 public virtual Type[] GetExportedTypes ()
407 return GetTypes (true);
410 public virtual Type GetType (String name, Boolean throwOnError)
412 return GetType (name, throwOnError, false);
415 public virtual Type GetType (String name) {
416 return GetType (name, false, false);
419 [MethodImplAttribute (MethodImplOptions.InternalCall)]
420 internal extern Type InternalGetType (Module module, String name, Boolean throwOnError, Boolean ignoreCase);
422 [MethodImplAttribute (MethodImplOptions.InternalCall)]
423 internal extern static void InternalGetAssemblyName (string assemblyFile, AssemblyName aname);
425 [MethodImplAttribute (MethodImplOptions.InternalCall)]
426 static extern void FillName (Assembly ass, AssemblyName aname);
428 [MonoTODO ("copiedName == true is not supported")]
429 public virtual AssemblyName GetName (Boolean copiedName)
432 // CodeBase, which is restricted, will be copied into the AssemblyName object so...
433 if (SecurityManager.SecurityEnabled) {
434 GetCodeBase (true); // this will ensure the Demand is made
437 return UnprotectedGetName ();
440 public virtual AssemblyName GetName ()
442 return GetName (false);
445 // the security runtime requires access to the assemblyname (e.g. to get the strongname)
446 internal virtual AssemblyName UnprotectedGetName ()
448 AssemblyName aname = new AssemblyName ();
449 FillName (this, aname);
453 public override string ToString ()
455 // note: ToString work without requiring CodeBase (so no checks are needed)
457 if (assemblyName != null)
460 assemblyName = get_fullname ();
464 public static String CreateQualifiedName (String assemblyName, String typeName)
466 return typeName + ", " + assemblyName;
469 public static Assembly GetAssembly (Type type)
472 return type.Assembly;
473 throw new ArgumentNullException ("type");
477 [MethodImplAttribute (MethodImplOptions.InternalCall)]
478 public static extern Assembly GetEntryAssembly();
480 internal Assembly GetSatelliteAssembly (CultureInfo culture, Version version, bool throwOnError)
483 throw new ArgumentNullException("culture");
484 Contract.EndContractBlock();
486 StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
487 String name = GetSimpleName() + ".resources";
488 return InternalGetSatelliteAssembly(name, culture, version, true, ref stackMark);
491 internal RuntimeAssembly InternalGetSatelliteAssembly (String name, CultureInfo culture, Version version, bool throwOnFileNotFound, ref StackCrawlMark stackMark)
493 AssemblyName an = new AssemblyName ();
495 an.SetPublicKey (GetPublicKey ());
496 an.Flags = GetFlags () | AssemblyNameFlags.PublicKey;
499 an.Version = GetVersion ();
501 an.Version = version;
503 an.CultureInfo = culture;
509 assembly = AppDomain.CurrentDomain.LoadSatellite (an, false);
510 if (assembly != null)
511 return (RuntimeAssembly)assembly;
512 } catch (FileNotFoundException) {
517 if (String.IsNullOrEmpty (Location))
520 // Try the assembly directory
521 string location = Path.GetDirectoryName (Location);
522 string fullName = Path.Combine (location, Path.Combine (culture.Name, an.Name + ".dll"));
523 if (!throwOnFileNotFound && !File.Exists (fullName))
526 return (RuntimeAssembly)LoadFrom (fullName);
530 Type _Assembly.GetType ()
532 // Required or object::GetType becomes virtual final
533 return base.GetType ();
537 [MethodImplAttribute (MethodImplOptions.InternalCall)]
538 private extern static Assembly LoadFrom (String assemblyFile, bool refonly);
540 public static Assembly LoadFrom (String assemblyFile)
542 return LoadFrom (assemblyFile, false);
546 public static Assembly LoadFrom (String assemblyFile, Evidence securityEvidence)
548 Assembly a = LoadFrom (assemblyFile, false);
550 if ((a != null) && (securityEvidence != null)) {
551 // merge evidence (i.e. replace defaults with provided evidences)
552 a.Evidence.Merge (securityEvidence);
559 [MonoTODO("This overload is not currently implemented")]
560 // FIXME: What are we missing?
561 public static Assembly LoadFrom (String assemblyFile, Evidence securityEvidence, byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm)
563 throw new NotImplementedException ();
567 public static Assembly LoadFrom (String assemblyFile, byte [] hashValue, AssemblyHashAlgorithm hashAlgorithm)
569 throw new NotImplementedException ();
572 public static Assembly UnsafeLoadFrom (String assemblyFile)
574 return LoadFrom (assemblyFile);
578 public static Assembly LoadFile (String path, Evidence securityEvidence)
581 throw new ArgumentNullException ("path");
582 if (path == String.Empty)
583 throw new ArgumentException ("Path can't be empty", "path");
584 // FIXME: Make this do the right thing
585 return LoadFrom (path, securityEvidence);
588 public static Assembly LoadFile (String path)
590 return LoadFile (path, null);
593 public static Assembly Load (String assemblyString)
595 return AppDomain.CurrentDomain.Load (assemblyString);
599 public static Assembly Load (String assemblyString, Evidence assemblySecurity)
601 return AppDomain.CurrentDomain.Load (assemblyString, assemblySecurity);
604 public static Assembly Load (AssemblyName assemblyRef)
606 return AppDomain.CurrentDomain.Load (assemblyRef);
610 public static Assembly Load (AssemblyName assemblyRef, Evidence assemblySecurity)
612 return AppDomain.CurrentDomain.Load (assemblyRef, assemblySecurity);
615 public static Assembly Load (Byte[] rawAssembly)
617 return AppDomain.CurrentDomain.Load (rawAssembly);
620 public static Assembly Load (Byte[] rawAssembly, Byte[] rawSymbolStore)
622 return AppDomain.CurrentDomain.Load (rawAssembly, rawSymbolStore);
626 public static Assembly Load (Byte[] rawAssembly, Byte[] rawSymbolStore,
627 Evidence securityEvidence)
629 return AppDomain.CurrentDomain.Load (rawAssembly, rawSymbolStore, securityEvidence);
632 [MonoLimitation ("Argument securityContextSource is ignored")]
633 public static Assembly Load (byte [] rawAssembly, byte [] rawSymbolStore, SecurityContextSource securityContextSource)
635 return AppDomain.CurrentDomain.Load (rawAssembly, rawSymbolStore);
638 public static Assembly ReflectionOnlyLoad (byte[] rawAssembly)
640 return AppDomain.CurrentDomain.Load (rawAssembly, null, null, true);
643 public static Assembly ReflectionOnlyLoad (string assemblyString)
645 return AppDomain.CurrentDomain.Load (assemblyString, null, true);
648 public static Assembly ReflectionOnlyLoadFrom (string assemblyFile)
650 if (assemblyFile == null)
651 throw new ArgumentNullException ("assemblyFile");
653 return LoadFrom (assemblyFile, true);
657 public static Assembly LoadWithPartialName (string partialName)
659 return LoadWithPartialName (partialName, null);
662 [MonoTODO ("Not implemented")]
663 public Module LoadModule (string moduleName, byte [] rawModule)
665 throw new NotImplementedException ();
668 [MonoTODO ("Not implemented")]
671 Module LoadModule (string moduleName, byte [] rawModule, byte [] rawSymbolStore)
673 throw new NotImplementedException ();
676 [MethodImplAttribute (MethodImplOptions.InternalCall)]
677 private static extern Assembly load_with_partial_name (string name, Evidence e);
680 public static Assembly LoadWithPartialName (string partialName, Evidence securityEvidence)
682 return LoadWithPartialName (partialName, securityEvidence, true);
686 * LAMESPEC: It is possible for this method to throw exceptions IF the name supplied
687 * is a valid gac name and contains filesystem entry charachters at the end of the name
688 * ie System/// will throw an exception. However ////System will not as that is canocolized
692 // FIXME: LoadWithPartialName must look cache (no CAS) or read from disk (CAS)
693 internal static Assembly LoadWithPartialName (string partialName, Evidence securityEvidence, bool oldBehavior)
696 throw new NotImplementedException ();
698 if (partialName == null)
699 throw new NullReferenceException ();
701 return load_with_partial_name (partialName, securityEvidence);
704 public Object CreateInstance (String typeName)
706 return CreateInstance (typeName, false);
709 public Object CreateInstance (String typeName, Boolean ignoreCase)
711 Type t = GetType (typeName, false, ignoreCase);
716 return Activator.CreateInstance (t);
717 } catch (InvalidOperationException) {
718 throw new ArgumentException ("It is illegal to invoke a method on a Type loaded via ReflectionOnly methods.");
724 Object CreateInstance (String typeName, Boolean ignoreCase,
725 BindingFlags bindingAttr, Binder binder,
726 Object[] args, CultureInfo culture,
727 Object[] activationAttributes)
729 Type t = GetType (typeName, false, ignoreCase);
734 return Activator.CreateInstance (t, bindingAttr, binder, args, culture, activationAttributes);
735 } catch (InvalidOperationException) {
736 throw new ArgumentException ("It is illegal to invoke a method on a Type loaded via ReflectionOnly methods.");
740 public Module[] GetLoadedModules ()
742 return GetLoadedModules (false);
745 public Module[] GetModules ()
747 return GetModules (false);
750 [MethodImplAttribute (MethodImplOptions.InternalCall)]
751 internal virtual extern Module[] GetModulesInternal ();
753 [MethodImplAttribute (MethodImplOptions.InternalCall)]
754 public extern virtual String[] GetManifestResourceNames ();
756 [MethodImplAttribute (MethodImplOptions.InternalCall)]
757 public extern static Assembly GetExecutingAssembly ();
759 [MethodImplAttribute (MethodImplOptions.InternalCall)]
760 public extern static Assembly GetCallingAssembly ();
762 [MethodImplAttribute (MethodImplOptions.InternalCall)]
763 internal static extern AssemblyName[] GetReferencedAssemblies (Assembly module);
765 [MethodImplAttribute (MethodImplOptions.InternalCall)]
766 private extern bool GetManifestResourceInfoInternal (String name, ManifestResourceInfo info);
768 public virtual ManifestResourceInfo GetManifestResourceInfo (String resourceName)
770 if (resourceName == null)
771 throw new ArgumentNullException ("resourceName");
772 if (resourceName.Length == 0)
773 throw new ArgumentException ("String cannot have zero length.");
774 ManifestResourceInfo result = new ManifestResourceInfo (null, null, 0);
775 bool found = GetManifestResourceInfoInternal (resourceName, result);
782 [MonoTODO ("Currently it always returns zero")]
791 internal virtual Module GetManifestModule () {
792 return GetManifestModuleInternal ();
795 [MethodImplAttribute (MethodImplOptions.InternalCall)]
796 internal extern Module GetManifestModuleInternal ();
799 public virtual extern bool ReflectionOnly {
800 [MethodImplAttribute (MethodImplOptions.InternalCall)]
804 public override int GetHashCode ()
806 return base.GetHashCode ();
809 public override bool Equals (object o)
811 if (((object) this) == o)
817 Assembly other = (Assembly) o;
818 return other._mono_assembly == _mono_assembly;
822 // Code Access Security
824 internal void Resolve ()
827 // FIXME: As we (currently) delay the resolution until the first CAS
828 // Demand it's too late to evaluate the Minimum permission set as a
829 // condition to load the assembly into the AppDomain
830 LoadAssemblyPermissions ();
831 Evidence e = new Evidence (UnprotectedGetEvidence ()); // we need a copy to add PRE
832 e.AddHost (new PermissionRequestEvidence (_minimum, _optional, _refuse));
833 _granted = SecurityManager.ResolvePolicy (e,
834 _minimum, _optional, _refuse, out _denied);
838 internal PermissionSet GrantedPermissionSet {
840 if (_granted == null) {
841 if (SecurityManager.ResolvingPolicyLevel != null) {
842 if (SecurityManager.ResolvingPolicyLevel.IsFullTrustAssembly (this))
843 return DefaultPolicies.FullTrust;
845 return null; // we can't resolve during resolution
853 internal PermissionSet DeniedPermissionSet {
855 // yes we look for granted, as denied may be null
856 if (_granted == null) {
857 if (SecurityManager.ResolvingPolicyLevel != null) {
858 if (SecurityManager.ResolvingPolicyLevel.IsFullTrustAssembly (this))
861 return DefaultPolicies.FullTrust; // deny unrestricted
869 [MethodImplAttribute (MethodImplOptions.InternalCall)]
870 extern internal static bool LoadPermissions (Assembly a,
871 ref IntPtr minimum, ref int minLength,
872 ref IntPtr optional, ref int optLength,
873 ref IntPtr refused, ref int refLength);
875 // Support for SecurityAction.RequestMinimum, RequestOptional and RequestRefuse
876 private void LoadAssemblyPermissions ()
878 IntPtr minimum = IntPtr.Zero, optional = IntPtr.Zero, refused = IntPtr.Zero;
879 int minLength = 0, optLength = 0, refLength = 0;
880 if (LoadPermissions (this, ref minimum, ref minLength, ref optional,
881 ref optLength, ref refused, ref refLength)) {
883 // Note: no need to cache these permission sets as they will only be created once
884 // at assembly resolution time.
886 byte[] data = new byte [minLength];
887 Marshal.Copy (minimum, data, 0, minLength);
888 _minimum = SecurityManager.Decode (data);
891 byte[] data = new byte [optLength];
892 Marshal.Copy (optional, data, 0, optLength);
893 _optional = SecurityManager.Decode (data);
896 byte[] data = new byte [refLength];
897 Marshal.Copy (refused, data, 0, refLength);
898 _refuse = SecurityManager.Decode (data);
903 public virtual PermissionSet PermissionSet {
904 get { return this.GrantedPermissionSet; }
907 public virtual SecurityRuleSet SecurityRuleSet {
908 get { throw CreateNIE (); }
913 static Exception CreateNIE ()
915 return new NotImplementedException ("Derived classes must implement it");
918 public virtual IList<CustomAttributeData> GetCustomAttributesData ()
920 return CustomAttributeData.GetCustomAttributes (this);
924 public bool IsFullyTrusted {
928 public virtual Type GetType (string name, bool throwOnError, bool ignoreCase)
933 public virtual Module GetModule (String name)
938 public virtual AssemblyName[] GetReferencedAssemblies ()
943 public virtual Module[] GetModules (bool getResourceModules)
948 [MonoTODO ("Always returns the same as GetModules")]
949 public virtual Module[] GetLoadedModules (bool getResourceModules)
954 public virtual Assembly GetSatelliteAssembly (CultureInfo culture)
959 public virtual Assembly GetSatelliteAssembly (CultureInfo culture, Version version)
964 public virtual Module ManifestModule {
965 get { throw CreateNIE (); }
968 public virtual bool GlobalAssemblyCache {
969 get { throw CreateNIE (); }
972 public virtual bool IsDynamic {
973 get { return false; }
976 public static bool operator == (Assembly left, Assembly right)
978 if ((object)left == (object)right)
980 if ((object)left == null ^ (object)right == null)
982 return left.Equals (right);
985 public static bool operator != (Assembly left, Assembly right)
987 if ((object)left == (object)right)
989 if ((object)left == null ^ (object)right == null)
991 return !left.Equals (right);
994 public virtual IEnumerable<TypeInfo> DefinedTypes {
996 foreach (var type in GetTypes ()) {
997 yield return type.GetTypeInfo ();
1002 public virtual IEnumerable<Type> ExportedTypes {
1003 get { return GetExportedTypes (); }
1006 public virtual IEnumerable<Module> Modules {
1007 get { return GetModules (); }
1010 public virtual IEnumerable<CustomAttributeData> CustomAttributes {
1011 get { return GetCustomAttributesData (); }