Bug 16351 - InternalsVisibleTo not working properly with strongly named assemblies
Summary: InternalsVisibleTo not working properly with strongly named assemblies
Status: RESOLVED NORESPONSE
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.10.1
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2013-11-19 16:18 UTC by mzxgiant
Modified: 2017-08-23 21:30 UTC (History)
6 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NORESPONSE

Description mzxgiant 2013-11-19 16:18:06 UTC
I have a Mono for Android project calling into a sequence of .NET-built PCLs DLL that are strongly named. Here's how it should work:

- Application (Mono for Android) executes methods in...
- SDK DLL (PCL) which calls helpers methods from...
- Common Library DLL (PCL) which invokes platform-specific methods from...
- Mono for Android DLL

All 3 of these are strongly named assemblies. In the Common Library, we have InternalsVisibleTo marked for both the SDK DLL and the Mono for Android DLL. In the Mono for Android DLL, we have InternalsVisibleTo marked for the Common Library.

When calling the SDK from our program *at runtime*, a call from the SDK to the Common Library fails, citing a MethodAccessException against an internally-marked method. This doesn't happen in any other build environment so far (.NET Windows/Silverlight both tested in the same way)

This occurs when InternalsVisibleTo is set up with the annotation written as:
[assembly: InternalsVisibleTo("Core.Subassembly, PublicKey=XYZ")]

If I change the annotation to not use public keys, such as:
[assembly: InternalsVisibleTo("Core.Subassembly")]

There are no issues.
Comment 1 mzxgiant 2013-11-19 16:48:01 UTC
Pardon, to clarify -- the 3 DLLs are strongly-named assemblies, the Mono for Android application is not.
Comment 2 JenniferMcDermott 2017-04-13 05:35:26 UTC
 I am sorry, but Mono for Android doesn't work the work as it should have according to your instructions. For example, Common Library DLL (PCL) doesn't  invoke platform-specific methods from http://customwritingcompany.com/. I have tried couple of times, but still it fails. Maybe I am doing something wrong, don't know.
Comment 3 Jon Douglas [MSFT] 2017-07-13 22:31:53 UTC
Can you please provide a valid reproduction that demonstrates this issue? This is a fairly old issue and we want to ensure that this bug does not go unnoticed if it is still a problem. Please upload a valid reproduction that has the minimal code and reproduction steps in order to reproduce this problem.

Thus I am marking this NEEDINFO for the tie being.
Comment 4 Cody Beyer (MSFT) 2017-08-23 21:30:14 UTC
Because we have not received a reply to our request for more information we are closing this issue. If you are still encountering this issue, please reopen the ticket with the requested information. Thanks!