[ClassInterface(ClassInterfaceType.None)]
[StructLayout (LayoutKind.Sequential)]
#if MOBILE
- public partial class Assembly : ICustomAttributeProvider {
+ public partial class Assembly : ICustomAttributeProvider, ISerializable
#else
- public abstract class Assembly : ICustomAttributeProvider, _Assembly, IEvidenceFactory, ISerializable {
+ public abstract class Assembly : ICustomAttributeProvider, _Assembly, IEvidenceFactory, ISerializable
#endif
- internal class ResolveEventHolder {
+ {
+ internal class ResolveEventHolder {
+#pragma warning disable 67
public event ModuleResolveEventHandler ModuleResolve;
+#pragma warning restore
}
internal class UnmanagedMemoryStreamForModule : UnmanagedMemoryStream
{
+#pragma warning disable 414
Module module;
+#pragma warning restore
public unsafe UnmanagedMemoryStreamForModule (byte* pointer, long length, Module module)
: base (pointer, length)
// Note: changes to fields must be reflected in _MonoReflectionAssembly struct (object-internals.h)
#pragma warning disable 649
- private IntPtr _mono_assembly;
+ internal IntPtr _mono_assembly;
#pragma warning restore 649
private ResolveEventHolder resolve_event_holder;
// We can't store the event directly in this class, since the
// compiler would silently insert the fields before _mono_assembly
//
- public event ModuleResolveEventHandler ModuleResolve {
+ public virtual event ModuleResolveEventHandler ModuleResolve {
[SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
add {
resolve_event_holder.ModuleResolve += value;
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern string InternalImageRuntimeVersion ();
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ static internal extern string GetAotId ();
+
// SECURITY: this should be the only caller to icall get_code_base
private string GetCodeBase (bool escaped)
{
string cb = get_code_base (escaped);
-#if !NET_2_1
+#if !MOBILE
if (SecurityManager.SecurityEnabled) {
// we cannot divulge local file informations
if (String.Compare ("FILE://", 0, cb, 0, 7, true, CultureInfo.InvariantCulture) == 0) {
return String.Empty;
string loc = get_location ();
-#if !NET_2_1
+#if !MOBILE
if ((loc != String.Empty) && SecurityManager.SecurityEnabled) {
// we cannot divulge local file informations
new FileIOPermission (FileIOPermissionAccess.PathDiscovery, loc).Demand ();
internal extern Type InternalGetType (Module module, String name, Boolean throwOnError, Boolean ignoreCase);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
- internal extern static void InternalGetAssemblyName (string assemblyFile, AssemblyName aname);
-
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- static extern internal void FillName (Assembly ass, AssemblyName aname);
+ internal extern unsafe static void InternalGetAssemblyName (string assemblyFile, out Mono.MonoAssemblyName aname, out string codebase);
public virtual AssemblyName GetName (Boolean copiedName)
{
// Try the assembly directory
string location = Path.GetDirectoryName (Location);
string fullName = Path.Combine (location, Path.Combine (culture.Name, an.Name + ".dll"));
- if (!throwOnFileNotFound && !File.Exists (fullName))
- return null;
- return (RuntimeAssembly)LoadFrom (fullName);
+ try {
+ return (RuntimeAssembly)LoadFrom (fullName);
+ } catch {
+ if (!throwOnFileNotFound && !File.Exists (fullName))
+ return null;
+ throw;
+ }
}
#if !MOBILE
public static Assembly LoadFrom (String assemblyFile, Evidence securityEvidence)
{
Assembly a = LoadFrom (assemblyFile, false);
-#if !NET_2_1
+#if !MOBILE
if ((a != null) && (securityEvidence != null)) {
// merge evidence (i.e. replace defaults with provided evidences)
a.Evidence.Merge (securityEvidence);
return LoadFrom (assemblyFile, true);
}
- [Obsolete]
+ [Obsolete("This method has been deprecated. Please use Assembly.Load() instead. http://go.microsoft.com/fwlink/?linkid=14202")]
public static Assembly LoadWithPartialName (string partialName)
{
return LoadWithPartialName (partialName, null);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private static extern Assembly load_with_partial_name (string name, Evidence e);
- [Obsolete]
+ [Obsolete("This method has been deprecated. Please use Assembly.Load() instead. http://go.microsoft.com/fwlink/?linkid=14202")]
public static Assembly LoadWithPartialName (string partialName, Evidence securityEvidence)
{
return LoadWithPartialName (partialName, securityEvidence, true);
public extern static Assembly GetCallingAssembly ();
[MethodImplAttribute (MethodImplOptions.InternalCall)]
- internal static extern AssemblyName[] GetReferencedAssemblies (Assembly module);
+ internal static extern IntPtr InternalGetReferencedAssemblies (Assembly module);
+
+ internal static AssemblyName[] GetReferencedAssemblies (Assembly module)
+ {
+ using (var nativeNames = new Mono.SafeGPtrArrayHandle (InternalGetReferencedAssemblies (module))) {
+ var numAssemblies = nativeNames.Length;
+ try {
+ AssemblyName [] result = new AssemblyName[numAssemblies];
+ const bool addVersion = true;
+ const bool addPublicKey = false;
+ const bool defaultToken = true;
+ const bool assemblyRef = true;
+ for (int i = 0; i < numAssemblies; i++) {
+ AssemblyName name = new AssemblyName ();
+ unsafe {
+ Mono.MonoAssemblyName *nativeName = (Mono.MonoAssemblyName*) nativeNames[i];
+ name.FillName (nativeName, null, addVersion, addPublicKey, defaultToken, assemblyRef);
+ result[i] = name;
+ }
+ }
+ return result;
+ } finally {
+ for (int i = 0; i < numAssemblies; i++) {
+ unsafe {
+ Mono.MonoAssemblyName* nativeName = (Mono.MonoAssemblyName*) nativeNames[i];
+ Mono.RuntimeMarshal.FreeAssemblyName (ref *nativeName, true);
+ }
+ }
+ }
+ }
+ }
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern bool GetManifestResourceInfoInternal (String name, ManifestResourceInfo info);
return other._mono_assembly == _mono_assembly;
}
-#if !NET_2_1
+#if !MOBILE
// Code Access Security
internal void Resolve ()
public virtual PermissionSet PermissionSet {
get { return this.GrantedPermissionSet; }
}
-
+#endif
+
public virtual SecurityRuleSet SecurityRuleSet {
get { throw CreateNIE (); }
}
-#endif
-
static Exception CreateNIE ()
{
return new NotImplementedException ("Derived classes must implement it");