Bug 32070 - Error MT2002: Failed to resolve “System.Void System.Security.Cryptography.SHA1Cng::.ctor()”
Summary: Error MT2002: Failed to resolve “System.Void System.Security.Cryptography.SHA...
Alias: None
Product: iOS
Classification: Xamarin
Component: BCL Class Libraries ()
Version: master
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2015-07-17 09:24 UTC by Ruud
Modified: 2015-07-23 09:02 UTC (History)
4 users (show)

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

Issue demonstration project (275.76 KB, application/zip)
2015-07-17 09:24 UTC, Ruud

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:

Description Ruud 2015-07-17 09:24:47 UTC
Created attachment 12087 [details]
Issue demonstration project

I have a PCL that references the HashLib PCL that I use for encryption.
This works fine when I build my iOS app without linking libraries.
When I set it to "link SDK assemblies" however, I get an error while building the iOS project.

MTOUCH: error MT2002: Failed to resolve "System.Void 
System.Security.Cryptography.SHA1Cng::.ctor()" reference from 
"System.Core, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"

I've attached an example solution that demonstrates the issue.
As soon as I make a call to the SHA1 encrypting method in HashLib, the linking error occurs.
I tried to exclude HashLib from linking, but that didn't help.
Comment 1 Sebastien Pouliot 2015-07-21 11:05:32 UTC
`SHA1Cng` is not a type that is part of XI mobile profile (on Windows this is a CNG provided version of SHA1, which makes not sense out of Windows where CNG is not available).

Either the HashLib assembly is mis-compiled or the wrong PCL profile is used.
Comment 2 Ruud 2015-07-23 09:02:20 UTC
I downloaded the HashLib source code and it turns out not to be PCL at all.. missed that completely.
Now I've extracted to code for SHA1 hashing from HashLib, moved it to separate PCL and referenced that in my Xamarin project.
This fixed the issue!