Skip to content

Conversation

@radekdoulik
Copy link
Member

  • it looks like with newer mono (or cecil?) we cannot write to the
    opened stream for reading, otherwise we will get sharing violation
    exception
  • this should fix part of #44529, other Tasks might need similar
    change

 - it looks like with newer mono (or cecil?) we cannot write to the
   opened stream for reading, otherwise we will get sharing violation
   exception

 - this should fix part of #44529, other Tasks might need similar
   change
@jonpryor
Copy link
Contributor

This PR should be reviewed and updated after PR #233 is merged.

I suspect that telling DirectoryAssemblyResolver to provide ReaderParameters.InMemory=true within the LinkAssemblies task will actually fix the problem, but that might not be the best solution.

res.Dispose ();

foreach (var pair in strippedAssemblies) {
File.Delete (pair.Key);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@radekdoulik @jonpryor won't this fail if the assembly is readonly. I can't remember if we fix those up before we run this task or not

@jonpryor
Copy link
Contributor

jonpryor commented Sep 27, 2016

Now that we've merged PR #233, we can tell DirectoryAssemblyResolver to load the assemblies as read/write. Let's see if this works:

diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/StripEmbeddedLibraries.cs b/src/Xamarin.Android.Build.Tasks/Tasks/StripEmbeddedLibraries.cs
index 85f29b8..ed1fa7c 100644
--- a/src/Xamarin.Android.Build.Tasks/Tasks/StripEmbeddedLibraries.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tasks/StripEmbeddedLibraries.cs
@@ -28,7 +28,10 @@ namespace Xamarin.Android.Tasks
            Log.LogDebugMessage ("StripEmbeddedLibraries Task");
            Log.LogDebugTaskItems ("  Assemblies: ", Assemblies);

-           using (var res = new DirectoryAssemblyResolver (Log.LogWarning, true)) {
+           var rp  = new ReaderParameters {
+               ReadWrite   = true,
+           };
+           using (var res = new DirectoryAssemblyResolver (Log.LogWarning, loadDebugSymbols:true, loadReaderParameters:rp)) {
                return Execute (res);
            }
        }
@@ -83,7 +86,7 @@ namespace Xamarin.Android.Tasks
                        WriteSymbols = assembly.MainModule.HasSymbols
                    };

-                   assembly.Write (assemblyPath, wp);
+                   assembly.Write (wp);
                }
            }
            return true;

@jonpryor
Copy link
Contributor

This PR is superseded by PR #239.

@jonpryor jonpryor closed this Sep 27, 2016
radical pushed a commit that referenced this pull request May 8, 2018
Most of them are using `ref` for `JniObjectReference` parameters. It
is well known case and is described in 25de1f3.

Added 3 more, which use `ref JniValueMarshalerState`. It is used here
by design and should be OK.
@github-actions github-actions bot locked and limited conversation to collaborators Feb 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

do-not-merge PR should not be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants