Open rolfbjarne opened 3 years ago
From @mandel-macaque on Wed, 10 Mar 2021 17:31:01 GMT
Hello, when you say 'not a simulator' does it mean that when you target a simulator the compilation does work. In that case we might be looking at a method that is removed by the linker:
Can't resolve the reference 'System.Void System.Security.Cryptography.DSACng::.ctor(System.Security.Cryptography.CngKey)', referenced from the method 'T Internal.Cryptography.Pal.Windows.PkcsPalWindows::GetPrivateKey(System.Security.Cryptography.X509Certificates.X509Certificate2,System.Boolean,System.Boolean)' in 'System.Security.Cryptography.Cng, Version=4.3.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
If that is the case, can you please use a configuration file to let the linker know that the method should not be removed. You can find how to do it in our documentation.
From @BlueFire-LLC on Thu, 11 Mar 2021 01:40:21 GMT
Yes, that is correct. It builds fine with the simulator but not with a real device. I looked at the linker documentation and I admit that I don't really understand how to create it for this scenario. Any chance you could create it using the build log and post it here? I'd really appreciate it. Thanks.
From @BlueFire-LLC on Thu, 11 Mar 2021 15:04:37 GMT
So I built the App with Linker behavior set to Don't Link and this is the error message I got. Does this help?
/Users/Administrator/Desktop/Development/BlueFire/Xamarin/Motorhomes/Motorhomes/Motorhomes.iOS/MTOUCH: Error MT5216: Native linking failed for '/Users/Administrator/Desktop/Development/BlueFire/Xamarin/Motorhomes/Motorhomes/Motorhomes.iOS/obj/iPhone/Debug/device-builds/iphone7.1-12.5.1/mtouch-cache/arm64/libSystem.Security.Cryptography.Pkcs.dll.dylib'. Please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new (MT5216) (Motorhomes.iOS)
From @BlueFire-LLC on Thu, 11 Mar 2021 15:28:11 GMT
And if I build with Linker Behavior set to Link All, it builds fine but the App crashes.
From @BlueFire-LLC on Thu, 11 Mar 2021 19:20:02 GMT
I created a Linker.config file and gave it a build action of LinkerDescription. I have no idea how to make the linker file work so I made it like below. This did not solve my problem and I need to get my App built for a critical production release. Is there any way to GO BACK TO VERSION 8.8?
<?xml version="1.0" encoding="UTF-8" ?>
<linker>
<assembly fullname="BlueFire">
<namespace fullname="System.Security.Cryptography" />
<type fullname="System.Security.Cryptography*" />
<type fullname="System.Security.Cryptography.Pkcs*" />
<type fullname="System.Security.Cryptography.Cng*" />
<type fullname="System.Security.Cryptography.CngKey*" />
<type fullname="System.Security.Cryptography.DSACng*" />
<type fullname="System.Security.Cryptography.X509Certificates*" />
<type fullname="System.Security.Cryptography.X509Certificates.X509Certificate2*" />
</assembly>
</linker>
From @albale221171 on Sat, 13 Mar 2021 13:43:21 GMT
I've the same problem but only in release. In debug it build and I can deploy the app in my iPad. But I can't build the .IPA file for the store. I'm completely blocked! There isn't a workaround?
From @stefanodelpero on Sat, 13 Mar 2021 17:47:06 GMT
Same thing here, I can't update my app anymore. My app works in simulator and also in debug, but the build release show the same exception. In my case the crypto library that causes the error is in the MailKit library (MimeKit).
From @BlueFire-LLC on Sun, 14 Mar 2021 17:50:12 GMT
MimeKit uses System.Security.Cryptography.Pkcs so maybe there is a coincidence here. How about it Microsoft. Can you fixe this or give us the ability to go back to version 8.8?
From @BlueFire-LLC on Wed, 17 Mar 2021 15:02:57 GMT
I have confirmed that, for me, it's MimeKit. I removed all references to it in my code and it builds fine. Not an acceptable solution but at least it is confirmed that it's MimeKit's reference to System.Security.Cryptography.Pkcs that is causing the issue. Note that this worked fine in VS version 8.8 so HOW ABOUT PROVIDING A WAY TO GO BACK TO 8.8?
From @jstedfast on Thu, 18 Mar 2021 18:35:20 GMT
Can someone link to a VSMac 8.8 build? Then customers can start building & releasing their products while a real fix can be figured out.
From @BlueFire-LLC on Thu, 18 Mar 2021 19:13:59 GMT
I was able to get a 8.8.8 build from Microsoft and installed it however it still failed with the same error. I don't think it matters on a Mac whether you have both builds installed since they are each self contained, right? I've attached the configurations (About VS) for each build. VSMac 8.8.8 Configuration.txt VSMac 8.9.2 Configuration.txt
From @BlueFire-LLC on Fri, 19 Mar 2021 02:39:58 GMT
I think for now we need to focus on getting the original issue fixed - Error MT2101 System.Security.Cryptography Error. Any updates Microsoft?
From @jstedfast on Fri, 19 Mar 2021 15:39:22 GMT
AFAIK, they are each self-contained, but perhaps the issue wasn't with the VSMac 8.8 to 8.9 update, but perhaps with a change to Xamarin.iOS or something?
From @mandel-macaque on Thu, 01 Apr 2021 13:14:29 GMT
I know we had issues with several linking problem, but I have no way to confirm we fixed. Can you please test with: https://bosstoragemirror.blob.core.windows.net/wrench/main/42776ce64de990066618cffdd23806a233b92f2f/4609644/package/xamarin.ios-14.17.0.283.pkg and https://bosstoragemirror.blob.core.windows.net/wrench/main/42776ce64de990066618cffdd23806a233b92f2f/4609644/package/xamarin.mac-7.11.0.283.pkg
From @BlueFire-LLC on Thu, 01 Apr 2021 15:05:06 GMT
Still same error with Xamain.ios Version: 14.17.0.283. It definitely is related to MailKit. When I revert back to MailKit version 2.6.0 (from 2.11) the error goes away. Mind you the previous VSMac version worked fine with MailKit 2.11.
From @jstedfast on Tue, 27 Apr 2021 15:16:47 GMT
FWIW, MimeKit's source code has no direct references to RSACng or DSACng, it only ever references the abstract RSA and DSA base classes.
The MimeKit.nuspec and the MimeKit.csproj also do not reference the System.Security.Cryptography.Cng assembly.
From @BlueFire-LLC on Tue, 27 Apr 2021 16:01:36 GMT
@jstedfast - I believe you're working the issue in this thread, right?
https://github.com/xamarin/xamarin-macios/issues/10802#issuecomment-811899388
From @jstedfast on Wed, 28 Apr 2021 00:16:40 GMT
I'm assuming they are related, yes.
From @mandel-macaque on Mon, 03 May 2021 13:54:13 GMT
@jstedfast did you test with the pkgs I linked?
From @BlueFire-LLC on Mon, 03 May 2021 14:36:39 GMT
@mandel-macaque - Yes, I did and the same error occurred.
From @jstedfast on Mon, 24 May 2021 18:04:35 GMT
@mandel-macaque what info do you need to reopen this?
I don't understand why the build is failing for @BlueFire-LLC since MimeKit/MailKit do not reference any of the Cng APIs or the nuget packages.
I can't test this myself because I no longer have access to any Macs.
From @rolfbjarne on Tue, 15 Jun 2021 18:50:53 GMT
MimeKit references System.Security.Cryptography.Pkcs
, which references System.Security.Cryptography.Cng
:
Loaded assembly 'MimeKit, Version=2.10.0.0, Culture=neutral, PublicKeyToken=bede1c8a46c66814' from /Users/Administrator/.nuget/packages/MimeKit/2.10.1/lib/netstandard2.1/MimeKit.dll
References: 'System.Security.Cryptography.Pkcs, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
[...]
Loaded assembly 'System.Security.Cryptography.Pkcs, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' from /Users/Administrator/.nuget/packages/system.security.cryptography.pkcs/4.7.0/runtimes/win/lib/netstandard2.1/System.Security.Cryptography.Pkcs.dll
References: 'System.Security.Cryptography.Cng, Version=4.3.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
[...]
Loaded assembly 'System.Security.Cryptography.Cng, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' from /Library/Frameworks/Xamarin.iOS.framework/Versions/14.14.2.5/lib/mono/Xamarin.iOS/Facades/System.Security.Cryptography.Cng.dll
Of particular interest is that the System.Security.Cryptography.Pkcs
NuGet references System.Security.Cryptography.Cng
v4.3.3.0, but gets v4.2.0.0 (from the Facade assemblies we ship, not the NuGet version).
This does not look like a MimeKit bug, but instead either something we're doing wrong (by resolving to the System.Security.Cryptography.Cng
we ship), or the System.Security.Cryptography.Pkcs
NuGet is doing something wrong.
@marek-safar would you happen to know how this is supposed to work?
From @rolfbjarne on Tue, 15 Jun 2021 19:23:28 GMT
I can reproduce this by just referencing the System.Security.Cryptography.Pkcs
, and passing --linkskip=System.Security.Cryptography.Pkcs
to mtouch, no need for MimeKit.
From @BlueFire-LLC on Tue, 15 Jun 2021 21:56:24 GMT
Thanks for looking into this. I'm still using MimeKit 2.6 where the current is 2.13. Sure will be nice to be able to use the current version.
From @marek-safar on Fri, 18 Jun 2021 17:05:40 GMT
This is an issue in the Mono implementation of the facade. DSACng type is missing in the facade https://github.com/mono/mono/blob/main/mcs/class/Facades/System.Security.Cryptography.Cng/TypeForwarders.cs#L44
Has anyone managed to fix the problem?
Same issue here anyone solved it without using older version MailKit?
Any update on this issue or are there any possible workarounds?
It's been almost 2 years that this issue has been open. Is there a technical challenge in adding the missing facade for DSACng to Mono?
From @BlueFire-LLC on Mon, 08 Mar 2021 16:11:51 GMT
Steps to Reproduce
Expected Behavior
Should build without errors (previous VS version worked)
Actual Behavior
Build fails with MT2101 error code
Environment
Build Logs
See attached file. BuildLog.txt
Example Project (If Possible)
Not possible, too large.
Copied from original issue xamarin/xamarin-macios#10802