-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug with xmlserializer when deployed to IIS #44995
Comments
@kostasxagoraris thanks for contacting us. This is likely caused by the linker being more agressive in 5.0, you can customize the linker following the steps here |
I was having the same issue, though on an asp.net hosted setup. Following @javiercn 's link I just decided to temporarily disable the crazy trimming by setting I also found this post helpful https://devblogs.microsoft.com/dotnet/app-trimming-in-net-5/ |
I tried different things but i still havent resolved the issue (disabling trimming all the way is one of them ) I will try again tomorrow. I m sure i m doing something wrong because the error insists |
I have disable trimming completely in my blazor webassembly client project and in the server project
like this i still get the same issue. |
I also used this command dotnet publish Panasoft.Web.MyData.Server.csproj -p:PublishTrimmed=false --self-contained --runtime win-x64 -c release I m a bit frustrated What else can I do? |
This seems to be an issue with the XML serializer running on WASM, the user disabled trimming and the problem still persisted |
Tagging subscribers to this area: @buyaa-n, @krwq, @jeffhandley Issue DetailsI have a project that was created originally with blazor web assembly 3.2. [NotSupportedException] : "Parent does not have a default constructor. The default constructor must be explicitly defined." The stack trace Source: System.Private.CoreLib TargetSite: DefineDefaultConstructor Of course there is no lack of default constructor anywhere. And anyway it works fine when running the site on visual studio and it worked fine under blazor 3.2 .net core 3.1. I tried publishing the site using different combinations of x64 x86 and target runtime. Do you need me to upload the published artifacts so that you have a look? Thanks for your advice.
|
I also tried to copy the files from the build directory to a seperate web site on the same iis that i use for my development and i had the same exact issue. |
Yet another similar issue protected async override Task OnParametersSetAsync()
{
using (StringReader text = new StringReader(TraceLog.Trace))
{
XPathDocument myXPathDoc = new XPathDocument(text);
XslCompiledTransform myXslTrans = new XslCompiledTransform();
string xmlStr = await Http.GetTraceXSLT(Navigation.ToAbsoluteUri("XSLTTraceToHTML.xslt").AbsoluteUri);
using (StringReader str = new StringReader(xmlStr))
using (var reader = System.Xml.XmlReader.Create(str))
{
myXslTrans.Load(reader);
StringWriter myWriter = new StringWriter();
myXslTrans.Transform(myXPathDoc, null, myWriter);
TraceHtml = myWriter.GetStringBuilder().ToString();
}
}
} And here is the error with .Net 5.0
|
@eerhardt I wonder whether it would be useful to create a meta label to add to any trim safety issues. |
I've been using the The original issue is a duplicate of #41389 and will be resolved with #44772 once it gets approved. The 2nd issue is a new one, it looks like the following code needs to be annotated correctly for the ILLinker to preserve the constructors correctly: runtime/src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/GenerateHelper.cs Lines 135 to 159 in aebd598
Side-note: The ILLink warnings caught this as well: runtime/src/libraries/System.Private.Xml/src/ILLink/ILLink.Suppressions.xml Lines 130 to 141 in aebd598
|
@kostasxagoraris - to try to get you unblocked on In your Blazor Client.csproj, add the following lines: <ItemGroup>
<TrimmerRootAssembly Include="System.Private.Xml" />
<TrimmerRootDescriptor Include="LinkerWorkaround.xml" />
</ItemGroup> And then create a file named <?xml version="1.0" encoding="utf-8" ?>
<linker>
<assembly fullname="System.Private.CoreLib">
<type fullname="System.Security.SecurityTransparentAttribute" />
</assembly>
</linker> I tried this myself, and it worked for me. Let me know if it works for you. We will get this fixed in net6.0. |
@eerhardt Thank you very much That solved all issues. Now it works smoothly!! |
I have a project that was created originally with blazor web assembly 3.2.
It used some more .net standard 2.0 projects to serialize a few classes from and to xml (also under .net standard 2.0).
I recently upgraded the blazor web app to .net 5.0 . (the projects under .net standard 2.0 remained as they were)
While everything on my development machines run smoothly when i deploy to iis I cant instantiate the xml serializer
[NotSupportedException] : "Parent does not have a default constructor. The default constructor must be explicitly defined."
The stack trace
at System.Reflection.Emit.TypeBuilder.DefineDefaultConstructor(MethodAttributes attributes)
blazor.webassembly.js:1 at System.Xml.Serialization.XmlSerializationILGen.GenerateBaseSerializer(String baseSerializer, String readerClass, String writerClass, CodeIdentifiers classes)
blazor.webassembly.js:1 at System.Xml.Serialization.TempAssembly.GenerateRefEmitAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace)
blazor.webassembly.js:1 at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location)
blazor.webassembly.js:1 at System.Xml.Serialization.XmlSerializer.GenerateTempAssembly(XmlMapping xmlMapping, Type type, String defaultNamespace, String location)
blazor.webassembly.js:1 at System.Xml.Serialization.XmlSerializer.GenerateTempAssembly(XmlMapping xmlMapping, Type type, String defaultNamespace)
blazor.webassembly.js:1 at System.Xml.Serialization.XmlSerializer..ctor(Type type, String defaultNamespace)
blazor.webassembly.js:1 at System.Xml.Serialization.XmlSerializer..ctor(Type type)
blazor.webassembly.js:1 at PanasoftUtilities.XMLStatic.Create_ClassObject_From_XMLDeserialization[AADEBooksParam](String xml, String& Errormessage, Type[] ExtraTypes)
Source: System.Private.CoreLib
TargetSite: DefineDefaultConstructor
Of course there is no lack of default constructor anywhere. And anyway it works fine when running the site on visual studio and it worked fine under blazor 3.2 .net core 3.1.
I tried publishing the site using different combinations of x64 x86 and target runtime.
I ve being struggling with the issue for 2 days. I don't know what else to do.
Do you need me to upload the published artifacts so that you have a look?
Thanks for your advice.
The text was updated successfully, but these errors were encountered: