Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

SecurityException only on IL2CPP and not Mono with Unity 2018.2.1f1

Discussion in 'Experimental Scripting Previews' started by bdovaz, Aug 2, 2018.

  1. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,052
    @strich @JoshPeterson

    Case number: 1066748


    WORKS!!

    Version:
    2018.2.1f1
    Scripting Runtime Version: .NET 4.x Equivalent
    Scripting Backend: Mono
    Api Compatibility Level: .NET Standard 2.0
    Player: Windows

    DOESN'T WORK!!

    Version: 2018.2.1f1
    Scripting Runtime Version: .NET 4.x Equivalent
    Scripting Backend: IL2CPP
    Api Compatibility Level: .NET Standard 2.0
    Player: Windows

    I get the following error when building to Windows only on IL2CPP. It works on Mono without any issues.

    The library I'm using is this: https://github.com/aspnet/DependencyInjection

    Despite of being inside "aspnet" it hasn't any dependencies.

    Other Microsoft open source libraries are built on top of that.

    We understand that being a library that targets .NET Standard 2.0 should work on all Unity platforms as it doesn't use Reflection.Emit.

    https://github.com/aspnet/DependencyInjection/blob/master/src/DI/DI.csproj#L5

    The specific exception I think that it throws from this specific line:

    https://github.com/Unity-Technologi...corlib/System.Reflection/AssemblyName.cs#L323

    We are also using other Microsoft libraries and also building ours on top of that but we are seeing that we can't build to any IL2CPP required (or capable) platform and it's a big stopper for us.

    I also have tested on Android and I have the same problem. I suppose that when you look at it you will test it on more platforms: WebGL, iOS, UWP...
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Thanks for the details, we will investigate this issue.
     
  3. jilleJr

    jilleJr

    Joined:
    Jan 21, 2015
    Posts:
    63
    Any updates on this? @JoshPeterson ?

    I'm experiencing the same error. I am receiving this every time I'm trying to get a string from a resource file `.resx` that's embedded in one of our DLLs.
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    It looks like our QA team was unable to reproduce this issue using the project submitted with this bug report. Can you submit a new bug report?
     
  5. jilleJr

    jilleJr

    Joined:
    Jan 21, 2015
    Posts:
    63
    Submitted: 1131451
     
    Last edited: Mar 5, 2019
    JoshPeterson likes this.
  6. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    It looks like the issue here is that the assembly which contains the resource does not have a public key set. IL2CPP is not handling this situation properly. You should be able to work around it by setting the public key for the assembly. We will be correcting this issue in a patch release soon.
     
    jilleJr likes this.
  7. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,052
    So why QA team was unable to reproduce my case? You would been able to fixed it many many months ago...il

    In either case I'm glad you found what the problem was and be able to fix it.
     
  8. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    I don't know the details about the original issue, sorry!
     
  9. bdrelling

    bdrelling

    Joined:
    Jul 2, 2013
    Posts:
    4
    I'm experiencing the same exactly problem. I'm running Unity 2018.3.6f1.

    Is IL2CPP considered experimental still?
     
  10. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    No, IL2CPP is fully supported. We expect to have this bug corrected in a 2018.3 release soon.
     
  11. jilleJr

    jilleJr

    Joined:
    Jan 21, 2015
    Posts:
    63
    Through my testing I did not get it working even though I signed my imported assemblies. It might be I did something wrong during the signing.
    But have you seen my submitted bug project? I have one signed assembly and it did not work.

    If you got it working on your machines, were there any specific procedures?

    That is awesome work!! Really quickly done. Can't wait :)
     
  12. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    I did have a look at the submitted project, but I did not notice that one of the assemblies was signed, sorry about that. I was able to get the project working with the bug fix I'm putting into a patch release. If you want to let me know which of the assemblies was signed (either here or via the bug report), I can take another look at it to see what is missing so that you can work around this issue.
     
  13. jilleJr

    jilleJr

    Joined:
    Jan 21, 2015
    Posts:
    63
    The `NetStandardSignedProject` assembly.
    Built one located at `\Assets\Plugins\NetStandardSignedProject\NetStandardSignedProject.dll`
    and `\DotnetAssemblies\NetStandardSignedProject` for the source.
     
  14. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    It looks like that assembly does have a public key. Unfortunately my work around is not enough then. We do need the code changes in order to make this work properly. Sorry about this. The fix should be out soon though.
     
  15. Pinkerator

    Pinkerator

    Joined:
    Jun 17, 2015
    Posts:
    77
    Hello, Josh!

    We got same problem here with "SecurityException: The public key is not valid" error message, but from Autofac library side. I wonder if your fix was successfully applied in some Unity version for that moment?

    Sincerely,
    Evgeniy
     
  16. jilleJr

    jilleJr

    Joined:
    Jan 21, 2015
    Posts:
    63
    @Pinkerator
    It was solved and released with 2018.3.10f1 (yesterday actually, 2019-03-25).

    You need to enable "useEmbeddedResources" which you can do using Josh's example: https://forum.unity.com/threads/enabling-embedded-resources-with-webgl.326069/
    Or simply change the "webGLUseEmbeddedResources" key in your ProjectSettings/ProjectSettings.asset to value of 1.

    ---

    @JoshPeterson Just tested it and mighty nice work!! Accept my blow kiss.

    Small thing: it doesn't work with strongly named (signed) assemblies, but at least it works at all with unsigned assemblies. <3 So nice this is working!

    Is there an ETA when this fix will be available in the 2019.* release?
     
  17. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    I've just heard about this. We'll make it work for signed assemblies as well.

    It should be fixed in 2019.1.0b9. I don't know quite when that should be out though.
     
  18. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    @Kalle-Jillheden

    So I've spoken too soon here. After some more investigation, we've found that supporting signed assembly loading for IL2CPP is not something Unity will do currently. We would need to include a good bit of code in the class libraries for cryptographic algorithms, and we don't believe the cost of the code size impact is worth the benefit of supporting signed assemblies now. We may consider support signed assemblies in the future, but for now we will not.
     
    jilleJr likes this.
  19. jilleJr

    jilleJr

    Joined:
    Jan 21, 2015
    Posts:
    63
    Quite fine with that. Sounds very reasonable, and this issue can be worked around.

    Still hoping though you find a good carrot and then also add support for .resx in signed assemblies while you're at it implementing the unknown "signed assembly"-required feature.

    Again great work on making it work at all!
     
  20. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,052
    @JoshPeterson The original issue is marked as fixed:

    https://issuetracker.unity3d.com/is...source-dot-resx-with-il2cpp-but-not-with-mono

    But I'm still seeing this problem on 2019.3.9f1 when it tries to get a embedded resource on Windows IL2CPP:

    How can I do this to at least workaround it right now?
     
  21. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    I'm not entirely sure why this is happening in your case. It looks like our QA team was unable to reproduce the original bug report you submitted. Then we fixed a different, but similar bug report. Maybe your case it different enough that it triggers some other issue.

    Would you mind trying to submit a new bug report?
     
  22. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,052
    @JoshPeterson

    Case 1240413

    The problem is that it doesn't happen on all machines. I think that's why they closed the other one... In this case I have the same problem.

    Could you take a look, please? The repro project it's really simple and straightforward to test.

    How can I do this to at least workaround it right now?
     
  23. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Thanks, our QA team will have a first look at this bug report.

    To set the public key, I think you can follow the instructions here: https://docs.microsoft.com/en-us/dotnet/standard/assembly/create-public-private-key-pair
     
  24. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,052
  25. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Ahh ok, that will be a problem then. The work around will not apply in your case, unfortunately.
     
  26. topjoy_unity14

    topjoy_unity14

    Joined:
    Jun 8, 2020
    Posts:
    2
    @JoshPeterson @bdovaz
    Hi, Friends.
    I am sufferring this PROBLEM when try to add Aliyun.OSS.Core.dll.
    Platform Android work Fine. But iOS Dont!

    DOESN'T WORK!!

    Version: 2018.4.19f1
    Scripting Runtime Version: .NET 4.x Equivalent
    Scripting Backend: IL2CPP
    Api Compatibility Level: .NET 4.x
    Player: iOS

    Below is output of sn command:
    sn -Tp .\Aliyun.OSS.Core.dll

    Microsoft (R) .NET Framework Strong Name Utility Version 4.0.30319.0
    Copyright (c) Microsoft Corporation. All rights reserved.

    Public key (hash algorithm: sha1):
    002400000480000094000000060200000024000052534131000400000100010045c2b8cbbfe7b4
    14dee24d990688805c04b57abb8292cec3cfbcf4c7f6bd8254c8ddea76f8ea035d106914678aae
    9db8ba4bf1669637043dbe62e1de2b978729cf6f3dd0080ac2209559371d26219b50309efda1d5
    1800de052b0a45c7c9238884eea4e7dc3c595b4930785a33a90ed4a6869285c3c04ad95245c0df
    c00d24cc

    Public key token is 0ad4175f0dac0b9b
     
  27. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Can you provide details about the specific error message that occurs?
     
  28. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,052
    The "official" QA response was this:

    In my case I checked with Visual Studio Installer the differences of what was installed in each one of the 2 machines (in one of them the error came out and in another one it didn't) but I also didn't see differences really...
     
  29. topjoy_unity14

    topjoy_unity14

    Joined:
    Jun 8, 2020
    Posts:
    2
    Hi, @JoshPeterson .
    Here is the error message:
    Code (CSharp):
    1. [2020-06-09 11:19:04.291][448][Exception]SecurityException: The public key is not valid.
    2. C# stack trace:
    3. System.Reflection.AssemblyName.InternalGetPublicKeyToken () (at <00000000000000000000000000000000>:0)
    4. System.Reflection.AssemblyName.get_FullName () (at <00000000000000000000000000000000>:0)
    5. System.AppDomain.LoadSatellite (System.Reflection.AssemblyName assemblyRef, System.Boolean throwOnError) (at <00000000000000000000000000000000>:0)
    6. System.Reflection.Assembly.InternalGetSatelliteAssembly (System.String name, System.Globalization.CultureInfo culture, System.Version version, System.Boolean throwOnFileNotFound, System.Threading.StackCrawlMark& stackMark) (at <00000000000000000000000000000000>:0)
    7. System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly (System.Globalization.CultureInfo lookForCulture, System.Threading.StackCrawlMark& stackMark) (at <00000000000000000000000000000000>:0)
    8. System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet (System.Globalization.CultureInfo culture, System.Collections.Generic.Dictionary`2[TKey,TValue] localResourceSets, System.Boolean tryParents, System.Boolean createIfNotExists, System.Threading.StackCrawlMark& stackMark) (at <00000000000000000000000000000000>:0)
    9. System.Resources.ResourceManager.InternalGetResourceSet (System.Globalization.CultureInfo requestedCulture, System.Boolean createIfNotExists, System.Boolean tryParents, System.Threading.StackCrawlMark& stackMark) (at <00000000000000000000000000000000>:0)
    10. System.Resources.ResourceManager.InternalGetResourceSet (System.Globalization.CultureInfo culture, System.Boolean createIfNotExists, System.Boolean tryParents) (at <00000000000000000000000000000000>:0)
    11. System.Resources.ResourceManager.GetString (System.String name, System.Globalization.CultureInfo culture) (at <00000000000000000000000000000000>:0)
    12. Aliyun.OSS.Util.HttpUtils..cctor () (at <00000000000000000000000000000000>:0)
    13. Aliyun.OSS.Util.OssUtils.UrlEncodeKey (System.String key) (at <00000000000000000000000000000000>:0)
    14. Aliyun.OSS.Commands.OssCommand.BuildRequest () (at <00000000000000000000000000000000>:0)
    15. Aliyun.OSS.Commands.OssCommand.AsyncExecute (System.AsyncCallback callback, System.Object state) (at <00000000000000000000000000000000>:0)
    16. Aliyun.OSS.Util.OssUtils.BeginOperationHelper[TCommand] (TCommand cmd, System.AsyncCallback callback, System.Object state) (at <00000000000000000000000000000000>:0)
    17. Topjoy.Engine.Loggers.OssClientHandles.OssClientHandler.AsyncPutFileObject (System.String bucketName, System.String relativeFilePath, System.String fileToUpload, System.AsyncCallback callback, Topjoy.Engine.Loggers.OssClientHandles.UploadState state) (at <00000000000000000000000000000000>:0)
     
  30. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    I don't think this is at all related to C++ tools installed. I'm unsure why our QA team suggested that. It looks like they have closed case. I can respond to it to re-open it?
     
  31. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Thanks - this does look like the same error as @bdovaz sees. Can you drop us a bug report as well? It does not hurt to have multiple cases for us to investigate.
     
  32. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,052
    Reopen it please.

    Yeah, that QA answer was weird.
     
  33. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Done.
     
  34. yadu

    yadu

    Joined:
    Dec 6, 2014
    Posts:
    9
    Is there a link to this issue on the tracker? I am having a similar problem when using nuget and the Humanizer library on webGL (works fine on windows)
     
  35. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    I don't see a public issue tracker link for this issue. If possible, can you submit a bug report for your case?
     
  36. yadu

    yadu

    Joined:
    Dec 6, 2014
    Posts:
    9
    I submitted a bug report. My last bug report was in 2015 for which I got a reply in 2017 :p I hope someone looks at this sooner. I tried changing the scripting backend to IL2CPP on windows and it failed there also (which I did not mention in the bug report, because I didn't know about it till after).
     
  37. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Thanks! Yes, I hope that it is processed sooner.
     
    yadu likes this.
  38. yadu

    yadu

    Joined:
    Dec 6, 2014
    Posts:
    9
    So I reported it and after a bunch of back and forth, this happened.

    upload_2020-8-27_17-3-1.png
     
  39. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Yep! Thanks for the bug report. It turns out the IL2CPP was encoding the public key information for assemblies incorrectly into the binary metadata file that it uses with the player build. Once this encoding was corrected, this project started to work properly.
     
    bdovaz and yadu like this.
  40. yadu

    yadu

    Joined:
    Dec 6, 2014
    Posts:
    9
    Lol! I just realised it was you who responded! :) Awesome! Thank you Josh!
     
    JoshPeterson likes this.
  41. Huszky

    Huszky

    Joined:
    Mar 25, 2018
    Posts:
    109
    @JoshPeterson I'm having the same issue on Il2CPP with unity 2020.1.5, when using the Micorost.Extensions.DependencyInjection dll. Am I missing something or is this not fixed yet?
    Code (CSharp):
    1. SecurityException: The public key is not valid.
    2.   at System.Reflection.AssemblyName.get_FullName () [0x00000] in <00000000000000000000000000000000>:0
    3.   at System.Reflection.Assembly.InternalGetSatelliteAssembly (System.String name, System.Globalization.CultureInfo culture, System.Version version, System.Boolean throwOnFileNotFound, System.Threading.StackCrawlMark& stackMark) [0x00000] in <00000000000000000000000000000000>:0
    4.   at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly (System.Globalization.CultureInfo lookForCulture, System.Threading.StackCrawlMark& stackMark) [0x00000] in <00000000000000000000000000000000>:0
    5.   at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet (System.Globalization.CultureInfo culture, System.Collections.Generic.Dictionary`2[TKey,TValue] localResourceSets, System.Boolean tryParents, System.Boolean createIfNotExists, System.Threading.StackCrawlMark& stackMark) [0x00000] in <00000000000000000000000000000000>:0
    6.   at System.Resources.ResourceManager.InternalGetResourceSet (System.Globalization.CultureInfo requestedCulture, System.Boolean createIfNotExists, System.Boolean tryParents, System.Threading.StackCrawlMark& stackMark) [0x00000] in <00000000000000000000000000000000>:0
    7.   at System.Resources.ResourceManager.InternalGetResourceSet (System.Globalization.CultureInfo culture, System.Boolean createIfNotExists, System.Boolean tryParents) [0x00000] in <00000000000000000000000000000000>:0
    8.   at System.Resources.ResourceManager.GetString (System.String name, System.Globalization.CultureInfo culture) [0x00000] in <00000000000000000000000000000000>:0
    9.   at Microsoft.Extensions.DependencyInjection.Resources.FormatNoConstructorMatch (System.Object p0) [0x00000] in <00000000000000000000000000000000>:0
    10.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite (Microsoft.Extensions.DependencyInjection.ServiceLookup.ResultCache lifetime, System.Type serviceType, System.Type implementationType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0
    11.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact (Microsoft.Extensions.DependencyInjection.ServiceDescriptor descriptor, System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain, System.Int32 slot) [0x00000] in <00000000000000000000000000000000>:0
    12.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0
    13.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory+<>c__DisplayClass7_0.<GetCallSite>b__0 (System.Type type) [0x00000] in <00000000000000000000000000000000>:0
    14.   at System.Reflection.MonoProperty+Getter`2[T,R].Invoke (T _this) [0x00000] in <00000000000000000000000000000000>:0
    15.   at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00000] in <00000000000000000000000000000000>:0
    16.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0
    17.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.CreateServiceAccessor (System.Type serviceType) [0x00000] in <00000000000000000000000000000000>:0
    18.   at System.Reflection.MonoProperty+Getter`2[T,R].Invoke (T _this) [0x00000] in <00000000000000000000000000000000>:0
    19.   at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00000] in <00000000000000000000000000000000>:0
    20.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope serviceProviderEngineScope) [0x00000] in <00000000000000000000000000000000>:0
    21.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService (System.Type serviceType) [0x00000] in <00000000000000000000000000000000>:0
    22.   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService (System.Type serviceType) [0x00000] in <00000000000000000000000000000000>:0
    23.   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService (System.IServiceProvider provider, System.Type serviceType) [0x00000] in <00000000000000000000000000000000>:0
    24.   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T] (System.IServiceProvider provider) [0x00000] in <00000000000000000000000000000000>:0
    25.   at Microsoft.Extensions.Hosting.HostBuilder.Build () [0x00000] in <00000000000000000000000000000000>:0
    26.   at SnakesAndLadders.UnityProject.DependencyInjection.SceneStartup.CreateServiceProvider () [0x00000] in <00000000000000000000000000000000>:0
    27.   at Injecter.Unity.InjectStarter.Awake () [0x00000] in <00000000000000000000000000000000>:0
    28.   at SnakesAndLadders.UnityProject.DependencyInjection.SceneStartup.Awake () [0x00000] in <00000000000000000000000000000000>:0
     
  42. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    The fix has not yet landed in a 2020.1 back port, but it will be landing, although I cannot say when it will be released.
     
  43. Huszky

    Huszky

    Joined:
    Mar 25, 2018
    Posts:
    109
    Would it be a solution to merge all of my dlls from nuget with ILMerge and then self sign it?
     
  44. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    I'm not sure if that would work, but it is worth a try.
     
  45. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,052
    As I already said via PM to @Huszky... Unity needs to fix that exception but apart from that you have a problem with stripping constructors. See:

    at Microsoft.Extensions.DependencyInjection.Resources.FormatNoConstructorMatch

    The problem is that because of that "SecurityException: The public key is not valid." you can't see what specific class it's stripping the constructor.

    You need to fix it with "link.xml" file.
     
    Huszky likes this.
  46. Huszky

    Huszky

    Joined:
    Mar 25, 2018
    Posts:
    109
    @bdovaz was right i fixed it with addig a linker file
     
  47. BeTechnology

    BeTechnology

    Joined:
    Jul 12, 2020
    Posts:
    7
    Hello, I use SignalR when I active the messageprotocol I have this error too, I check all my assembly with sn -Tp command tool and all dll have a Public key.
    I use link.xml too.
    If I desactivate messageprotocol (default protocol is json),the app works perfecty.

    How do you know which file have a problem ?
    My log:
    Code (CSharp):
    1. AndroidPlayer(ADB@127.0.0.1:34999) SecurityException: The public key is not valid.
    2.   at System.Reflection.AssemblyName.InternalGetPublicKeyToken () [0x00000] in <00000000000000000000000000000000>:0
    3.   at System.Reflection.AssemblyName.get_FullName () [0x00000] in <00000000000000000000000000000000>:0
    4.   at System.AppDomain.LoadSatellite (System.Reflection.AssemblyName assemblyRef, System.Boolean throwOnError) [0x00000] in <00000000000000000000000000000000>:0
    5.   at System.Reflection.Assembly.InternalGetSatelliteAssembly (System.String name, System.Globalization.CultureInfo culture, System.Version version, System.Boolean throwOnFileNotFound, System.Threading.StackCrawlMark& stackMark) [0x00000] in <00000000000000000000000000000000>:0
    6.   at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly (System.Globalization.CultureInfo lookForCulture, System.Threading.StackCrawlMark& stackMark) [0x00000] in <00000000000000000000000000000000>:0
    7.   at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet (System.Globalization.CultureInfo culture, System.Collections.Generic.Dictionary`2[TKey,TValue] localResourceSets, System.Boolean tryParents, System.Boolean createIfNotExists, System.Threading.StackCrawlMark& stackMark) [0x00000] in <00000000000000000000000000000000>:0
    8.   at System.Resources.ResourceManager.InternalGetResourceSet (System.Globalization.CultureInfo requestedCulture, System.Boolean createIfNotExists, System.Boolean tryParents, System.Threading.StackCrawlMark& stackMark) [0x00000] in <00000000000000000000000000000000>:0
    9.   at System.Resources.ResourceManager.InternalGetResourceSet (System.Globalization.CultureInfo culture, System.Boolean createIfNotExists, System.Boolean tryParents) [0x00000] in <00000000000000000000000000000000>:0
    10.   at System.Resources.ResourceManager.GetString (System.String name, System.Globalization.CultureInfo culture) [0x00000] in <00000000000000000000000000000000>:0
    11.   at System.Resources.ResourceManager.GetString (System.String name) [0x00000] in <00000000000000000000000000000000>:0
    12.   at System.SR.GetResourceString (System.String resourceKey, System.String defaultString) [0x00000] in <00000000000000000000000000000000>:0
    13.   at System.SR.get_NoConstructorMatch () [0x00000] in <00000000000000000000000000000000>:0
    14.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite (Microsoft.Extensions.DependencyInjection.ServiceLookup.ResultCache lifetime, System.Type serviceType, System.Type implementationType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0
    15.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact (Microsoft.Extensions.DependencyInjection.ServiceDescriptor descriptor, System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain, System.Int32 slot) [0x00000] in <00000000000000000000000000000000>:0
    16.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0
    17.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0
    18.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory+<>c__DisplayClass7_0.<GetCallSite>b__0 (System.Type type) [0x00000] in <00000000000000000000000000000000>:0
    19.   at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00000] in <00000000000000000000000000000000>:0
    20.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0
    21.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites (System.Type serviceType, System.Type implementationType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain, System.Reflection.ParameterInfo[] parameters, System.Boolean throwIfCallSiteNotFound) [0x00000] in <00000000000000000000000000000000>:0
    22.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite (Microsoft.Extensions.DependencyInjection.ServiceLookup.ResultCache lifetime, System.Type serviceType, System.Type implementationType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0
    23.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact (Microsoft.Extensions.DependencyInjection.ServiceDescriptor descriptor, System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain, System.Int32 slot) [0x00000] in <00000000000000000000000000000000>:0
    24.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateEnumerable (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0
    25.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0
    26.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory+<>c__DisplayClass7_0.<GetCallSite>b__0 (System.Type type) [0x00000] in <00000000000000000000000000000000>:0
    27.   at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00000] in <00000000000000000000000000000000>:0
    28.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0
    29.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites (System.Type serviceType, System.Type implementationType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain, System.Reflection.ParameterInfo[] parameters, System.Boolean throwIfCallSiteNotFound) [0x00000] in <00000000000000000000000000000000>:0
    30.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite (Microsoft.Extensions.DependencyInjection.ServiceLookup.ResultCache lifetime, System.Type serviceType, System.Type implementationType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0
    31.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateOpenGeneric (Microsoft.Extensions.DependencyInjection.ServiceDescriptor descriptor, System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain, System.Int32 slot, System.Boolean throwOnConstraintViolation) [0x00000] in <00000000000000000000000000000000>:0
    32.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateOpenGeneric (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0
    33.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0
    34.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory+<>c__DisplayClass7_0.<GetCallSite>b__0 (System.Type type) [0x00000] in <00000000000000000000000000000000>:0
    35.   at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00000] in <00000000000000000000000000000000>:0
    36.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0
    37.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites (System.Type serviceType, System.Type implementationType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain, System.Reflection.ParameterInfo[] parameters, System.Boolean throwIfCallSiteNotFound) [0x00000] in <00000000000000000000000000000000>:0
    38.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite (Microsoft.Extensions.DependencyInjection.ServiceLookup.ResultCache lifetime, System.Type serviceType, System.Type implementationType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0
    39.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateOpenGeneric (Microsoft.Extensions.DependencyInjection.ServiceDescriptor descriptor, System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain, System.Int32 slot, System.Boolean throwOnConstraintViolation) [0x00000] in <00000000000000000000000000000000>:0
    40.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateOpenGeneric (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0
    41.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0
    42.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory+<>c__DisplayClass7_0.<GetCallSite>b__0 (System.Type type) [0x00000] in <00000000000000000000000000000000>:0
    43.   at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00000] in <00000000000000000000000000000000>:0
    44.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0
    45.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites (System.Type serviceType, System.Type implementationType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain, System.Reflection.ParameterInfo[] parameters, System.Boolean throwIfCallSiteNotFound) [0x00000] in <00000000000000000000000000000000>:0
    46.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite (Microsoft.Extensions.DependencyInjection.ServiceLookup.ResultCache lifetime, System.Type serviceType, System.Type implementationType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0
    47.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact (Microsoft.Extensions.DependencyInjection.ServiceDescriptor descriptor, System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain, System.Int32 slot) [0x00000] in <00000000000000000000000000000000>:0
    48.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0
    49.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0
    50.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory+<>c__DisplayClass7_0.<GetCallSite>b__0 (System.Type type) [0x00000] in <00000000000000000000000000000000>:0
    51.   at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00000] in <00000000000000000000000000000000>:0
    52.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0
    53.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.CreateServiceAccessor (System.Type serviceType) [0x00000] in <00000000000000000000000000000000>:0
    54.   at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00000] in <00000000000000000000000000000000>:0
    55.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope serviceProviderEngineScope) [0x00000] in <00000000000000000000000000000000>:0
    56.   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService (System.Type serviceType) [0x00000] in <00000000000000000000000000000000>:0
    57.   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService (System.Type serviceType) [0x00000] in <00000000000000000000000000000000>:0
    58.   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T] (System.IServiceProvider provider) [0x00000] in <00000000000000000000000000000000>:0
    59.   at Microsoft.AspNetCore.SignalR.Client.HubConnectionBuilder.Build () [0x00000] in <00000000000000000000000000000000>:0
    60.   at Assets.Service.BaseService..ctor () [0x00000] in <00000000000000000000000000000000>:0
    61.   at Assets.Service.PlayerService..ctor () [0x00000] in <00000000000000000000000000000000>:0
    62.   at LoginManager+<Login>d__10.MoveNext () [0x00000] in <00000000000000000000000000000000>:0
    63.   at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0
    64.   at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0
    65.   at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0
    66.   at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0
    67.   at System.Threading.Tasks.AwaitTaskContinuation.InvokeAction (System.Object state) [0x00000] in <00000000000000000000000000000000>:0
    68.   at System.Threading.Tasks.AwaitTaskContinuation.RunCallback (System.Threading.ContextCallback callback, System.Object state, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0
    69.   at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.Run (System.Threading.Tasks.Task task, System.Boolean canInlineContinuationTask) [0x00000] in <00000000000000000000000000000000>:0
    70.   at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0
    71.   at System.Threading.Tasks.Task.FinishStageThree () [0x00000] in <00000000000000000000000000000000>:0
    72.   at System.Threading.Tasks.Task`1[TResult].TrySetResult (TResult result) [0x00000<message truncated>
     
  48. VolodymyrBS

    VolodymyrBS

    Joined:
    May 15, 2019
    Posts:
    150
    most likely your link.xml doesn't include all required types.

    if you look at stack trace carefully you will see
    at System.SR.get_NoConstructorMatch ()


    seems constructor of some class is missin and it's try to load error text
     
  49. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Also, please be sure you are using the latest version of Unity on each release stream. The fix for this issue has landed relatively recently.