Skip to content
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

UWP apps having nullable DateTime-properties compiled with the NET Native Toolchain crashes #648

Closed
Nilzor opened this issue Sep 30, 2016 · 5 comments
Labels
Milestone

Comments

@Nilzor
Copy link

Nilzor commented Sep 30, 2016

I'm saying "stuff" because I really have no idea what the cause or even the exact scenario under which this happens. The error occurs only when doing release builds with the .NET Native toolchain enabled, which is a prerequisite for being allowed to publish on the Windows 10 Store

I'm getting IllegalOperationException "Attempt to read/load private field property in managed properties" sometimes when doing GetProperty. The exception breaks on the GetPropetry-line itself

My property is defined as follows:

public readonly static PropertyInfo<DateTime?> DueProperty = RegisterProperty<DateTime?>(c => c.Due);
public DateTime? Due
{
    get { return GetProperty(DueProperty); }
    set { SetProperty(DueProperty, value); }
}

I'll see if I can make a reproducable example solution later. I'm running Windows 10586 and the latest CSLA_UWP as of today.

@rockfordlhotka
Copy link
Member

rockfordlhotka commented Sep 30, 2016

You may be running into a case where the native compiler is optimizing away parts of your code that you need, but it can't identify that you need (e.g. anything invoked via reflection or dynamic code).

You might try adding a <assemblyname>.rd.xml file to your project in the Properties folder to prevent that optimization. For example:

<?xml version="1.0" encoding="utf-8"?>
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
  <Library Name="Csla.Uwp">
    <Assembly Name="Csla" Activate="Required All" Browse="Required All" Serialize="Required All" Dynamic="Required All" />
  </Library>
</Directives>

From here: https://github.com/MarimerLLC/csla/blob/master/Source/Csla.Uwp/Properties/Csla.Uwp.rd.xml

Replace the library name and assembly name with your project's values.

@Nilzor
Copy link
Author

Nilzor commented Sep 30, 2016

Sounds like a good theory. I couldn't immediately get it working though but I'll try more tomorrow, maybe on a simpler project.

Am I to place the file in the main UWP app project, or in the library project that depends on CSLA? Or both? Is "Library name" the name the is displayed in the Solution Explorer?

@Nilzor
Copy link
Author

Nilzor commented Oct 1, 2016

I have now tested further with a clean test project and found that it only happens with Nullable DateTime properties. Maybe others as well, but that's the one that breaks it for me.

I haven't been able to amend the problem yet. Would be awesome if you or someone else could look at it:

https://github.com/Nilzor/csla-uwp-ntcfail

@Nilzor Nilzor changed the title Compiling a UWP app using the NET Native Toolchain breaks stuff UWP apps having nullable DateTime-properties compiled with the NET Native Toolchain crashes Oct 3, 2016
@rockfordlhotka
Copy link
Member

I don't see the problem occurring with the current version of UWP and related tooling. It seemed unlikely that it was a CSLA issue before, and this would appear to confirm that it was a UWP issue that Microsoft must have resolved.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants