Skip to content

Blazor WebAssembly -dieselization is working in the local code but it does not work when we deployed the Blazor to IIS server #48249

Closed

Description

@rogerge88

Describe the bug

"we are not using blazer server .We are using Blazor WebAssembly . and the issue that the dieselization is working in the local code but it does not work when we deployed the Blazor to IIS server."

Struct data(Color : IEquatable) cannot "deserialize" when deployed the Blazor to IIS server.
It worked fine working in the local code.

Error message......
Newtonsoft.Json.JsonSerializationException: Error converting value "12, 12" to type
'System.Nullable`1[System.Drawing.Size]'. Path 'mapLayers[0].marker.icon.size', line 1, position 1272.
---> System.ArgumentException: Could not cast or convert from System.String to System.Drawing.Size.
at Newtonsoft.Json.Utilities.ConvertUtils.EnsureTypeAssignable(Object value, Type initialType, Type targetType)
at Newtonsoft.Json.Utilities.ConvertUtils.ConvertOrCast(Object initialValue, CultureInfo culture, Type targetType)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
Exception_EndOfInnerExceptionStack
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)

To Reproduce

Exceptions (if any)

Further technical details

  • ASP.NET Core version
  • Include the output of dotnet --info
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version

Activity

  1. pranavkm commented on Feb 11, 2021

    @pranavkm
    Contributor

    It might be that a type converter is being trimmed. FYI @eerhardt

  2. rogerge88 commented on Feb 11, 2021

    @rogerge88
    Author

    Thanks. We are using NET5 not NET core 3.1
    IDE: VS 2019

  3. rogerge88 commented on Feb 11, 2021

    @rogerge88
    Author

    we are already used false . but that did not fix the issue. Thanks

  4. eerhardt commented on Feb 11, 2021

    @eerhardt
    Member

    @rogerge88 - can you provide a link to a project (or a .zip) that reproduces the issue?

  5. rogerge88 commented on Feb 11, 2021

    @rogerge88
    Author

    @eerhardt OK and I will upload it. Thanks

  6. rogerge88 commented on Feb 11, 2021

    @rogerge88
    Author

    @eerhardt Zip file is bigger than 10 MB(about 50 MB after zip) , how to upload it?Thanks

  7. eerhardt commented on Feb 11, 2021

    @eerhardt
    Member

    Can you delete the bin and obj folders before zipping?

  8. rogerge88 commented on Feb 12, 2021

    @rogerge88
    Author

    Struct.Issue.zip
    @eerhardt Thank you and the zip file has been uploaded. Please let me know if you need more data.Thanks

  9. transferred this issue fromdotnet/aspnetcoreon Feb 12, 2021
  10. ghost added
    untriaged
    on Feb 12, 2021
  11. 18 remaining items

  12. eerhardt commented on Feb 16, 2021

    @eerhardt
    Member

    Reopening, as we need to fix the product to support this out of the box.

  13. rogerge88 commented on Feb 17, 2021

    @rogerge88
    Author

    @eerhardt Thank you for helps and we had it to work based on your "to workaround this for now, to unblock yourself 1 & 2..." . However, after implemented the fix you provided the Devop throw below error during build:
    ------------Error message below-----
    021-02-16T16:18:53.3623358Z C:\Program Files\dotnet\sdk\5.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ILLink.targets(88,5): error MSB6006: "dotnet.exe" exited with code 255. [Client.csproj]
    2021-02-16T16:18:53.3637813Z Optimizing assemblies for size, which may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
    2021-02-16T16:18:53.3654873Z C:\Program Files\dotnet\sdk\5.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ILLink.targets(41,5): error NETSDK1144: Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false. [Client.csproj]

  14. eerhardt commented on Feb 17, 2021

    @eerhardt
    Member

    It sounds like the linker is throwing an exception for some reason. Is that all the error logs you are getting? It should be printing out what exception occurred, which will point you to what is wrong.

    I'm just guessing, but you might have the wrong file name in your .csproj. Make sure you are pointing to the right file in

      <ItemGroup>
        <TrimmerRootDescriptor Include="ILLink.Descriptors.xml" />
      </ItemGroup>

    And make sure the ILLink.Descriptors.xml file exists on the machine and is next to the Client .csproj.

  15. rogerge88 commented on Feb 17, 2021

    @rogerge88
    Author

    @eerhardt The issues has been fixed and we can get the correct result coming from the server.

    Thank you!

  16. rogerge88 commented on Mar 10, 2021

    @rogerge88
    Author

    @eerhardt and all, The "same issue happened when getting the enum attribute. it works locally but not after deployment" . The following is the code for you to duplicate the issue. Thanks.
    ------------Code below----------

    public static string GetEnumCategory<T>(this T enumValue)
                where T : struct, IConvertible
            {
                if (!typeof(T).IsEnum)
                    return null;
                var enumCategory = enumValue.ToString();
                var fieldInfo = enumValue.GetType().GetField(enumValue.ToString());
                if (fieldInfo != null)
                {
                    var attrs = fieldInfo.GetCustomAttributes(typeof(CategoryAttribute), false);
                    if (attrs != null && attrs.Length > 0)
                    {
                        enumCategory = ((CategoryAttribute)attrs[0]).Category;
                    }
                }
                return enumCategory;
            }
            
      public enum AnEnum
        {
            
            [Description("Somthing"), Category("SomthingCat")]
            Somthing = 52,
        }
     var category = EnumHelper.GetEnumCategory(AnEnum.Somthing);
    

    category local result = "category", after deployment result = "PropertyCategorycategory"

    Please let me know if you need more info about this issue. Thanks!

  17. rogerge88 commented on Mar 12, 2021

    @rogerge88
    Author

    -----Could you please give us some suggestion for above the new related issue? Thanks!

  18. eerhardt commented on Mar 12, 2021

    @eerhardt
    Member

    @rogerge88 - This is a new issue. In the future, please open a new issue when you have a new scenario.

    I've opened #49554 for this new issue.

    To work around it until we can get a fix out, you can set:

      <PropertyGroup>
        <UseSystemResourceKeys>false</UseSystemResourceKeys>
      </PropertyGroup>

    in your .csproj.

  19. rogerge88 commented on Mar 12, 2021

    @rogerge88
    Author

    @eerhardt Got it and thank you very much!

    We will check this new issue at #49554. Thanks!

  20. self-assigned this
    on May 11, 2021
  21. eerhardt commented on May 11, 2021

    @eerhardt
    Member

    This may be fixed by the work we've done for facades. Assigning to myself to re-test.

  22. eerhardt commented on May 21, 2021

    @eerhardt
    Member

    This is now fixed with the latest bits. Closing.

  23. ghost locked as resolved and limited conversation to collaborators on Jun 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-System.Drawingbuglinkable-framework

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions