-
Notifications
You must be signed in to change notification settings - Fork 1.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
.NET MAUI Set iOS Linker Behavior to "LinkAll" throws XamlParseException: 'Position 9:37. Cannot assign property "Source": Property does not exist. #16861
Comments
I'm having the same issue! |
Here's the assignment Source="Resources/Styles/Colors.xaml" |
Same thing happens for me in existing project. Really looking forward for it to be fixed in nearest update |
Same problem here. After latest Preview VS update [17.4.0 Preview 2.1]. I always use "Link Framework SDKs Only" and it has the same problem. |
Still having exactly the same problem @hbraasch described |
I now got the sample MAUI app to run under Preview VS update [17.4.0 Preview 2.1] and XCode 13.4.1 by selecting .NET7 as the framework!!! Now to start converting my old apps to .NET7 to see if that works. Seems it's not as simple as changing the [net6.0-] to [net7.0-] in the .csproj file :-( Any help with that shall be appreciated. |
Old "real" app is now also working after upgrading to .NET7. |
@hbraasch says this issue is fixed in .NET7 but is this fix going to make it into .NET6 as well? |
@hbraasch can you open a new issue with why this is not working:
It should work 100% as the API is the same and mostly bug fixes and smaller features. |
@StephaneDelcroix could it be that the xamlc is not compiling the xaml that contains the source property? @cyourch @TamerIrdais @bodyasakalo I am wondering if you can test something and trick the linker into keeping some fields/properties. Somewhere in the app - maybe in the MauiProgram.cs: class MauiProgram {
#pragma warning disable 0219, 0649
static bool falseflag = false;
static MauiProgram ()
{
if (falseflag) {
var rd = new ResourceDictionary { Source = "" };
}
}
#pragma warning restore 0219, 0649
// ...
} @rolfbjarne @jonathanpeppers do we have docks on how to stop linking particular assemblies? EDIT I think this is the docs that shows how you can add a xml file to skip linking on the Microsoft.Maui.Countrols.dll: |
Hi @vsfeedback. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
@mattleibow I tried your code but it didn't work, also I don't know what is it supposed to do because falseflag is always false so new ResourceDictionary is never called so what is this code supposed to do? |
Ah yeah, so it doesn't do anything except trick the linker into keeping that property. However, if adding it did not stop the linker from causing the error, then something else has gone wrong and @StephaneDelcroix will have to share some expert opinions. |
@rolfbjarne unless we taught the linker to be even smarter and it detects this magic code as no op and removes it and keeps on linking? |
@mattleibow it wouldn't surprise me if the linker had gotten that smart. this should ensure the linker doesn't remove it: static bool falseflag = Environment.GetEnvironmentVariable ("inexistent") == "inexistent"; since the linker will not be able to determine that |
@rolfbjarne I don't know what you guys mean, where should I put this line? and it it supposed to fix this bug? because I tried and it didn't, here is my code inside MauiProgram.cs file and I don't understand how these lines are going to keep the resource files Colors.xaml and Styles.xaml inside App.xaml file from getting stripped out:
|
I wouldn't recommend using You will likely need to preserve things as mentioned here: https://github.com/dotnet/linker/blob/main/docs/data-formats.md |
Thank you @jonathanpeppers but this is still a bug and I need a fix for it, there must be a way to stop linker from trimming Source.xml and Colors.xml files from the default template of the MAUI project right? there has to be. |
@TamerIrdais do you have XamlCompilation turned off? https://learn.microsoft.com/en-us/dotnet/maui/xaml/xamlc The linker should see your use of any types in Why is this a blocker? Why do you need |
@jonathanpeppers No I didn't turn off XamlCompilation and its ON by default. I needed LinkAll because it used to give compilation errors on my own frameworks when I don't use that flag and the compilation error goes away when I use LinkAll, now on latest VS 2022 17.3.6 that problem seems to be fixed so I can avoid using LinkAll for now but still this is a bug and should be fixed, right? Its active on the default MAUI project template after you change the linker to LinkAll for iOS with no other changes to the project, can you guys event reproduce it on your side? its a bug and should be fixed because in Xamarin we were able to use LinkAll with no problems. |
@jonathanpeppers Any update on this issue? |
WPF does not even work with trimming enabled, it would be a large project to support this for .NET MAUI. Any framework that uses System.Reflection heavily is in the same boat. If you still want to use
As you encounter errors like |
Hi @vsfeedback. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
So the original bug I reported is not getting solved by you guys, am I correct? If you solved that issue I can handle my problem with my frameworks but I can't even test my app using "LinlAll" now. |
Any update on this issue? I need this fixed ASAP please. |
Still getting this issue in IOS on .NET 7. Tried setting linker settings to "Don't link" then cleaned and rebuilt project. Still getting the same error and a notification for Visual Studio for mac to set my linker settings to "Don't link" though I believe I have already done that. Using visual studio for mac 17.5 preview build 437 |
@TamerIrdais did you end up finding a workaround for this? |
@ajay-mundi no I got no where with it and as you can see no one from Microsoft side is even saying we will investigate it or when it will be fixed. |
I can confirm we are experiencing the same issue on Net7. |
Still experiencing the issue in NET 7.0 |
Related #12316 |
@PureWeen I have reported this bug over 6 months ago and still got no fix, can you please when is this going to be fixed? |
Same issue on my projects |
Same Issue for me as well Guys |
The same issue is here. I use "Link Framework SDKs Only" during release process, and have a problem with a properties that uses binding. Microsoft.Maui.Controls text is displayed instead of source value. .Net 7.0. |
How is this still an issue? jeez |
Verified this issue with Visual Studio Enterprise 17.7.0 Preview 2.0. Can repro on iOS platform with .NET MAUI template project. |
Still an issue for me too. Please prioritize |
We've discussing with the .NET team that owns the trimmer, and it does not appear this is feasible in the .NET 8 timeframe. We have other issues filed to try to solve all trimmer warnings on the Android side, for example: ^^ So, we'd ideally have completed this one first before looking at .NET MAUI. Moving this to the backlog for now, but it may become more important in the future as we try to support other runtimes like NativeAOT. For now, I would not recommend using |
We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process. |
This issue has been moved from a ticket on Developer Community.
[severity:I'm unable to use this version]
Create new .NET MAUI app and set the iOS Linker Behavior to "LinkAll", build and run to iOS device or simulator and you will get below exception on app start:
Microsoft.Maui.Controls.Xaml.XamlParseException: 'Position 9:37. Cannot assign property "Source": Property does not exist, or is not assignable, or mismatching type between value and property'.
Help is needed ASAP please.
Original Comments
Feedback Bot on 8/28/2022, 07:35 PM:
(private comment, text removed)
Tamer Irdais on 9/2/2022, 00:49 AM:
(private comment, text removed)
Original Solutions
(no solutions)
The text was updated successfully, but these errors were encountered: