Bug 12174 - Missing method get_Name in assembly, type System.Security.Claims.ClaimsIdentity
Summary: Missing method get_Name in assembly, type System.Security.Claims.ClaimsIdentity
Status: RESOLVED INVALID
Alias: None
Product: Runtime
Classification: Mono
Component: General ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-05-08 19:12 UTC by catgotyrtongue
Modified: 2013-10-15 07:03 UTC (History)
4 users (show)

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


Attachments
Compiled code on Windows with Visual Studio 2012 (5.00 KB, application/x-msdownload)
2013-05-08 19:12 UTC, catgotyrtongue
Details


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 GitHub or Developer Community 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 INVALID

Description catgotyrtongue 2013-05-08 19:12:23 UTC
Created attachment 3938 [details]
Compiled code on Windows with Visual Studio 2012

Compile this program on Windows with Visual Studio 2012:

class Program
{
    static void Main(string[] args)
    {
        var identity = System.Security.Principal.WindowsIdentity.GetCurrent();

        if (System.Type.GetType("Mono.Runtime") == null)
        {
            // shouldn't be run on mono
            // shouldn't crash either
            System.Console.WriteLine(identity.Name);
        }
    }
}

Run it on mono:

$ mono ConsoleApplication1.exe
Missing method get_Name in assembly /home/ubuntu/ConsoleApplication1.exe, type System.Security.Claims.ClaimsIdentity

Unhandled Exception:
System.TypeLoadException: Could not load type 'System.Security.Claims.ClaimsIdentity' from assembly 'ConsoleApplication1'.
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type 'System.Security.Claims.ClaimsIdentity' from assembly 'ConsoleApplication1'.

$ mono --version
Mono JIT compiler version 3.0.11 (master/11471bc Fri May  3 12:35:16 UTC 2013)

$ uname -a
Linux server 3.8.4-x86_64-linode #1 SMP Mon Mar 25 16:00:34 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux
Comment 1 Rodrigo Kumpera 2013-05-17 13:18:51 UTC
You cannot use unavailable types and methods in the same method you check for mono presence.

Move usage to System.Security.Claims.ClaimsIdentity in a separate method and use the type test guard to call it or not.
Comment 2 catgotyrtongue 2013-05-17 14:16:46 UTC
This type and methods are available, it works perfectly if it's compiled with mono.
Comment 3 Rodrigo Kumpera 2013-05-17 14:20:59 UTC
Then I fail to see what's the problem you're suggesting that exists.
Comment 4 catgotyrtongue 2013-05-17 14:22:35 UTC
If I compile my library (e.g. Npgsql) on Windows and then want to distribute it with my application, it will not run on mono.
Comment 5 Rodrigo Kumpera 2013-05-17 15:12:01 UTC
Because it will throw the above exception, right? I explained why it will and how to avoid it. It's not a bug but just how things work.

You cannot have missing types/methods on methods that are executed, even if you don't call them.
Comment 6 Timothy 2013-10-15 07:03:03 UTC
I don't think this is resolved.
Sure your first reply pointed out why he gets the TypeLoad exception
but it does not solve/explain why the following code works fine if you compile with mono and doesn't work when you compile with .NET (visual studio)

var identity = System.Security.Principal.WindowsIdentity.GetCurrent();
Console.WriteLine(identity.Name)

The proper execution of the code above should not depend on 
the compiler that has been used.

If you still refuse to see the issue,
consider the following example:

http://stackoverflow.com/a/16276287/28149

compile it with gmcs (mono) and with csc (.net) and try to run
both versions with mono.