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

Package 1.0.6.3 install fails for UWP App #33

Closed
fgoulet opened this issue Jul 8, 2016 · 42 comments
Closed

Package 1.0.6.3 install fails for UWP App #33

fgoulet opened this issue Jul 8, 2016 · 42 comments
Labels

Comments

@fgoulet
Copy link

fgoulet commented Jul 8, 2016

In a new blank UWP App with Microsoft.NETCore.UniversalWindowsPlatform 5.1.0, I got a lot of downgrade warnings and this error:
System.Reflection.Emit.ILGeneration 4.0.1 provides a compile-time reference assembly for System.Reflection.Emit.ILGeneration on UAP,Version=v10.0, but there is no
run-time assembly compatible with win10-x86-aot.

When I bump the version to Microsoft.NETCore.UniversalWindowsPlatform 5.2.0, the downgrade warnings are gone but still the same error.

@StefH
Copy link
Collaborator

StefH commented Jul 9, 2016

If possible, create an example app. With and without references to system.linq.dynamic.core

And also checkout my example project https://github.com/StefH/System.Linq.Dynamic.Core/tree/master/test-uap/UniversalWindowsApp and see the differences.

@fgoulet
Copy link
Author

fgoulet commented Jul 9, 2016

With Microsoft.NETCore.UniversalWindowsPlatform 5.1.0, my app works fine just like your example project. I tried to upgrade your example project to 5.2.0 and I got the same error. I need to upgrade my app to 5.2.0 in order to use EFCore 1.0 RTM. Could you try to upgrade your example app to Microsoft.NETCore.UniversalWindowsPlatform 5.2.0 ?

@fgoulet
Copy link
Author

fgoulet commented Jul 9, 2016

I forgot to mention that I have added System.Linq.Dynamic.Core project to the solution of my app to make it works with 5.1.0, like your example project.

@StefH
Copy link
Collaborator

StefH commented Jul 9, 2016

Ok. Enough details I think. Thanks for this analysis. I'll take a look in some days.

@StefH
Copy link
Collaborator

StefH commented Jul 15, 2016

Strange error, maybe no related to this library but see also

NuGet/Home#3034
dotnet/efcore#4802

@fgoulet
Copy link
Author

fgoulet commented Jul 15, 2016

AutoMapper seems to had the same problem and apparently were able to fix it
Can't install Automapper 5.0 into Windows 10 UWP #1448

@jogibear9988
Copy link
Contributor

In Automapper I think this was the fixing commit:AutoMapper/AutoMapper@f3e345d

@StefH
Copy link
Collaborator

StefH commented Jul 20, 2016

By replacing some dependencies for .NetStandard by the "NETStandard.Library": "1.6.0" dependency ?

@jogibear9988
Copy link
Contributor

Don't know. I only found this commit. I don't use UWP

@fgoulet
Copy link
Author

fgoulet commented Jul 26, 2016

I think the commit mostly remove the code for .Net Core that depends on ILGeneration. I have removed the aot runtimes (ahead of time) from my project.json of my UWP app and I can now successfully install package 1.0.5. I won't be able to build my app for .Net Native but at least I can pursue the development until a compatible version of system.Reflection.Emit.ILGeneration (hopefully!) comes up.

@aline-almeida
Copy link

Hi!
Same thing here. Blank UWP App (either with .NETCore 5.1.0 or 5.2.2).
Can't install nuget package.
A lot of downgrade warnings and incompability errors with win10-arm-aot, win10-x64-aot and win10-x86-aot from System.Reflection.Emit.ILGeneration 4.0.1

@StefH
Copy link
Collaborator

StefH commented Aug 3, 2016

Can somebody point me in some direction how to solve this?

@StefH StefH added the bug label Aug 3, 2016
@fgoulet
Copy link
Author

fgoulet commented Aug 5, 2016

Until there is a version of System.Reflection.Emit.ILGeneration compatible with the aot runtimes (.Net Native), I don't see what can be done.

@ravensorb
Copy link

Anyone have any idea on this one?

@StefH
Copy link
Collaborator

StefH commented Sep 27, 2016

Maybe it's related to scottksmith95/LINQKit#47

I'll apply same fix and publish new NuGet.

@StefH
Copy link
Collaborator

StefH commented Sep 27, 2016

NuGet created (System.Linq.Dynamic.Core 1.0.6.3) which maybe solves this, please retest.

@fgoulet
Copy link
Author

fgoulet commented Sep 27, 2016

1.0.6.3, same error for me.

From the blog post Introducing .NET Standard, the following is stated:

Runtime specific APIs. For example, the ability to generate and run code on the fly using reflection emit. This cannot work on .NET platforms that do not have a JIT compiler, such as .NET Native on UWP or via Xamarin’s iOS tool chain.

That problably means it is not possible to generate type with TypeBuilder in .Net Native.

@ravensorb
Copy link

So if that is the case then shouldn't it target a different profile so that it cannot be installed in profiles that do not support it?

@StefH StefH changed the title Package 1.0.5 install fails for UWP App Package 1.0.6.3 install fails for UWP App Sep 27, 2016
@StefH
Copy link
Collaborator

StefH commented Sep 27, 2016

@MattWhilden Maybe you can shed some light here ?

Can you take a look at the supported frameworks and advice maybe to change / remove some ? Like is adding netstandard 2.0 as described in the blog post above already supported ?

@MattWhilden
Copy link

Unfortunately, building against netstandard will only get you slightly further. The core problem is that Reflection.Emit is completely unsupported for platforms that only support ahead of time compilation (read: UWP). These platforms currently have no way to generate native code for any IL that you generate... that's what the warning is attempting to say (poorly). It looks like core functionality of this library needs RefEmit to work so it's probably going to be in pretty bad shape even if you can get it to restore and build.

That said, I'm a bit surprised that this causes a restore failure. I would have expected runtime failures (PlatformNotSupportedException/NotImplementedException etc). I'll have to chase someone down tomorrow to see what the deal is.

We have some strategies about how we might enable this in the future but nothing to share right now.

@fgoulet
Copy link
Author

fgoulet commented Sep 29, 2016

@MattWhilden The restore failure started with Microsoft.NETCore.UniversalWindowsPlatform 5.2

Really looking forward for a way to emit types in UWP, hopefully in a near future :). Thank you for the clarification anyway.

@MattWhilden
Copy link

Thanks. That'll help me track down what happened... As I said, I'd expect that this would just cause runtime exceptions and not package restore problems.

Adding runtime dynamism (JIT compiler? Interpreter??) is something we're interested in attempting for a bunch of reasons. As you could imagine, attaching that kind of component into a compiler/runtime pipeline after the fact has lots of gnarly technical issues.

Question: For your scenarios, does having RefEmit be available but very slow (aka interpreter) actually help? Or do you find that the things you use RefEmit for end up being on performance critical paths? If this takes us way off topic, I'm happy to move it to email. We love getting feedback/issues/etc at [email protected]. :-D

@fgoulet
Copy link
Author

fgoulet commented Sep 29, 2016

It's certainly right on topic for System.Linq.Dynamic.Core :) My only scenario for now is to use this library in a UWP app. The library make use of RefEmit TypeBuilder to create anonymous type to be use in select clause of linq query build at run time. I'm not sure but I think performance is not critical. Maybe @StefH can step in and add more insight.

@StefH
Copy link
Collaborator

StefH commented Sep 29, 2016

Correct, the https://github.com/StefH/System.Linq.Dynamic.Core/blob/master/src/System.Linq.Dynamic.Core/DynamicClassFactory.cs is used to generate a fields, getters, setters, constructors based on the properties and types you want on a DynamicClass class.

If there is another way to do this in UWP, please provide some details.

@jogibear9988
Copy link
Contributor

I solved this problem for winrt here: jogibear9988/System.Linq.Dynamic@c746fd1

StefH added a commit that referenced this issue Sep 30, 2016
@StefH
Copy link
Collaborator

StefH commented Sep 30, 2016

@jogibear9988 : Thanks for your example.

@fgoulet : Please test if the new version 1.0.6.4 can be installed on UAP 5.2.2 and also works as expected.

@jogibear9988
Copy link
Contributor

As you may have seen, I did one more commit for this after the one I showed you: jogibear9988/System.Linq.Dynamic@e2dbfc7

@fgoulet
Copy link
Author

fgoulet commented Sep 30, 2016

Yes, with the dependency on System.Refection.Emit removed, it install fine on 5.5.2.
It is very interesting but this new way to generate anonymous type seems to work only with up to 9 properties. I suppose this is because there is 9 constructors on DynamicClass ? If there is a way to make it work with an unspecified number of properties, it could actually fit my needs.

@StefH
Copy link
Collaborator

StefH commented Sep 30, 2016

I tried to make it generic, but I could not get ot working.

How many do you need ? 64 max , or 256max ?

@fgoulet
Copy link
Author

fgoulet commented Sep 30, 2016

It is for adhoc query, so the user choose the fields that he needs. It would be nice not to have a limit on the number of fields but I guest the UI would become impracticable with more than, say 128.

I try replacing all the constructors of DynamicClass with this one:
public DynamicClass(params KeyValuePair<string, object>[] propertylist)
{
foreach (var kvp in propertylist)
{
_properties.Add(kvp.Key, kvp.Value);
}
}

Now, the challenge is to modify ExpressionParser.CreateNewExpression to make Expression.New call this constructor. I did not succeed so far but I have the feeling that it should be feasible.

@StefH
Copy link
Collaborator

StefH commented Sep 30, 2016

I also tried

public DynamicClass(params KeyValuePair<string, object>[] propertylist)

But I run into problems here:

var constructor = type.GetTypeInfo().DeclaredConstructors.First(x => x.GetParameters().Count() == properties.Count());
return Expression.New(constructor, parameters);

@fgoulet
Copy link
Author

fgoulet commented Sep 30, 2016

Yes, same as me. Since the number of constructors is down to one, it it possible to get it with

var constructor = type.GetTypeInfo().DeclaredConstructors.First();

but I could not make Expression.New call the constructor with params

@jogibear9988
Copy link
Contributor

I don't know exactly why i did how its implemented, but i think i also tried in other ways. Maybe I've time to look over ?

But we could also generate this class via tt

Von meinem iPhone gesendet

Am 30.09.2016 um 17:21 schrieb Frederic Goulet [email protected]:

Yes, same as me. Since the number of constructors is down to one, it it possible to get it with

var constructor = type.GetTypeInfo().DeclaredConstructors.First();

but I could not make Expression.New call the constructor with params

You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

@StefH
Copy link
Collaborator

StefH commented Sep 30, 2016

tt/t4 is not supported in .net core

However I can just generate a class myself with 128 constructors. ..... done...

@StefH
Copy link
Collaborator

StefH commented Oct 1, 2016

Trying to follow this example https://rogeralsing.com/2008/02/28/linq-expressions-creating-objects/, but no luck still...

@jogibear9988
Copy link
Contributor

jogibear9988 commented Oct 1, 2016

@StefH
have you also seen the changes in my 2nd commit? there is a converter to translate this to a anonymous type in normal .net

StefH added a commit that referenced this issue Oct 2, 2016
@StefH
Copy link
Collaborator

StefH commented Oct 2, 2016

@fgoulet I fixed the issue the constructor. Can you please review the code ? If all is fine, I'll create a new NuGet/

@fgoulet
Copy link
Author

fgoulet commented Oct 2, 2016

@StefH Nice work! I tested it and works fine.

@StefH
Copy link
Collaborator

StefH commented Oct 3, 2016

Closing

@StefH StefH closed this as completed Oct 3, 2016
@StefH StefH mentioned this issue Oct 3, 2016
@MattWhilden
Copy link

Just catching up after being away for a few days and y'all seem to have crushed this issue. Let me know if there are other things you find lingering. I'll +1 all of the concerns that have been expressed in this thread into our internal issues tracking this stuff.

@ddelapasse2
Copy link

Hi, Having trouble understanding this thread. Sounds like DynamicLinq should work with UAP, but doesn't work for me. Maybe because my UWP version is 5.2.2? Anyway to make this combo work?

I see
System.Linq.Dynamic 1.0.0 is not compatible with UAP,Version=v10.0.
all the way through
System.Linq.Dynamic 1.0.7 is not compatible with UAP,Version=v10.0

project.json
{
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2",
"Microsoft.Toolkit.Uwp.Notifications": "1.2.0",
"System.Collections.NonGeneric": "4.3.0",
"System.Security.Cryptography.Algorithms": "4.3.0"
},
"frameworks": {
"uap10.0": {}
},
"runtimes": {
"win10-arm": {},
"win10-arm-aot": {},
"win10-x86": {},
"win10-x86-aot": {},
"win10-x64": {},
"win10-x64-aot": {}
}
}

@StefH
Copy link
Collaborator

StefH commented Jun 28, 2017

Closed by #72 ?

@StefH StefH closed this as completed Jun 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

7 participants