-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
For non-deterministic builds WPF application crashes on resource dictionary load #2517
Comments
I can reproduce this. When using msbuild, i get these warnings:
In Visual Studio, I get the same warnings:
Running the exe crashes exactly how @the-black-wolf describes. but running it using I removed
This is what I got:
Finally, there is a error message that says that the problem is:
|
/cc @SamBent - not a WPF bug. |
@vatsan-madhavan I beg to differ, I think this is a bug in |
Actually, by looking at the code, the bug is in the file https://github.com/dotnet/wpf/blob/master/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Navigation/BaseUriHelper.cs |
Can you guys please confirm this as bug and relabel the issue? |
Hmm, is there some process by which I can bring attention to this BUG. And it is a bug, and it is a regression. In .net framework 4.7.2/4.8 wpf this works just fine. |
@vatsan-madhavan I think @the-black-wolf is correct that this is a WPF bug. The documentation for System.Version assumes the following:
So it doesn't support wildcard versioning. WPF is calling into I think either:
Thoughts? @the-black-wolf I just created a .NET Framework project with |
@SamBent @vatsan-madhavan Don't know what was going through my head earlier about versioning, ignore that. @the-black-wolf I think I see the difference here. In .NET Framework you're likely using I think the issue is that pathway doesn't really exist anymore. Using the I think you might be able to turn off auto-generation of the assembly info via setting |
Hmm, not sure this will work since My understanding above was incorrect (again). What might be happening is that the |
Erm, wildcard versions are supposed to be resolved during build, not end up in any assembly attributes, the runtime should never see them. At least that was how it worked in Desktop.
If wildcard versions are not supported anymore by the build system it should raise a build error and not literally transcribe the placeholder into the version attribute. Wildcard versions at runtime are useless because they can only be resolved during a build. Looking at dotnet/roslyn#22660 it sounds like wildards should be supported if deterministic build is off though |
@weltkante Yes, I was getting a bit stream of consciousness above so probably a mess of half-conclusions. My current thinking (have to validate with binlogs) is:
Again, this is just from experimentation right now, I have to comb through logs to see what is happening when (unless someone knows offhand). Hopefully that condenses and clarifies the word salad I was typing last night : - ) |
So I went out and did some testing and I actually haven't been able to get this to work on .NET Framework. If you simply take a new .NET Framework WPF project, set @the-black-wolf When you were saying this would break a forward port of a .NET Framework app, is this the method you were using? If not, can you tell me the method you are using? |
Just to confirm you comment, yes the framework version that works uses Also, setting |
Hmm, that seems to work for me. Here's my solution with two apps, one core one frame, both created that way. Maybe I did something wrong, I played around a bit with this. |
I think thats a VS/msbuild issue not specific to WPF, setting Its particular bad because when you configure the versions from the UI (in contrasts to editing the project file) you cannot see the difference between You set Assembly Version from project property UI to include a placeholder. In old-style projects this edits the AssemblyInfo.cs and doesn't touch AssemblyFileVersion. In new style projects this will leave FileVersion unspecified and generate both AssemblyVersion and AssemblyFileVersion to include the placeholder at build even though the UI shows Assembly file version as having no placeholder. The project property UI is not representing what gets generated. Specifying both
in a new style project generates the correct attributes even though the UI just looks like as if FileVersion wasn't specified. |
@the-black-wolf Got it, my issue was I was using a full page in the I am not sure there is anything to fix in WPF specifically. You can get more specific if you'd like and instead of setting |
@weltkante Have you tried adding a new |
Well, I would think its fixable, no? Ultimately, wildcard or not in build, the dictionary is loaded on startup, no? At that point you have a running assembly from which to source it and a way to determine its version. |
@rladuca ok instantiating a page breaks new-style WPF projects even if they specify |
@the-black-wolf Whether or not we can do something so that @weltkante Correct, as long as you don't use set the versions via properties it works. Using a property breaks the generated code for InitializeComponent in I think the most reasonable answer is that, in .NET Framework, you altered the AssemblyInfo (either directly or via UI) to get this behavior and you should continue to do so in .NET Core. That makes the most sense from a porting perspective and also works with minimal effort. |
@the-black-wolf I sort of see what you're saying. We could, potentially use I don't have a good answer for any compat concerns that may cause. @SamBent @vatsan-madhavan do you have any opinions on potentially changing the generated code for InitializeComponent to query the executing assembly version instead of using a string? |
You might need to annotate An alternative option not relying on GetExecutingAssembly is emitting |
Here is a summary of what we know and what has been discussed. Issue
Workaround
Potential Fix
|
Thanks. The workaround works ok on our projects, so we'll use that in anticipation of the official fix. |
If project is set to be non-deterministic and AssemblyVersion uses wildcards, the application fails while loading resource dictionaries. It seem to try to parse Version object from wildcard string from meta (?) instead of determining concrete running assembly version, either that or there is a bug in Version parser.
Note: I understand there are benefits to deterministic, but that is not the topic, non-deterministic should not be a showstopper for wpf core, especially when porting existing applications and follow-up processes.
Steps to reproduce:
Expected behavior
A working application?
Actual behavior
Application crashes with unhandled exception immediately on start. Stack trace is:
The text was updated successfully, but these errors were encountered: