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

System.InvalidProgramException #50

Closed
OscarKoo opened this issue Nov 21, 2017 · 11 comments
Closed

System.InvalidProgramException #50

OscarKoo opened this issue Nov 21, 2017 · 11 comments
Assignees
Labels
Milestone

Comments

@OscarKoo
Copy link

@dadhi

I newly got this Exception on testing server.
"
System.InvalidProgramException: Common Language Runtime detected an invalid program.
at (Closure5 , TimeSlice ) at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext()
at System.Linq.Enumerable.Any[TSource](IEnumerable1 source) at Csh.Hcis.GC.VueScheduler.Common.Extensions.LinqExtensions.<AnyAsync2>d__111.MoveNext()
"

Here is the code:
20171121155927

Here is the compiled delegate, it has 5 same variables (strange?).
20171121155741

Is there any clue?

@dadhi
Copy link
Owner

dadhi commented Nov 21, 2017

Interesting, as I understood whatever is inside Where2 is expression to compile?
If so, what is the type of w, w.DateType and w.Id ?

@OscarKoo
Copy link
Author

"whatever is inside Where2 is expression to compile" - Yes, as last time the picture I showed you. (if you remember)

"what is the type of w, w.DateType and w.Id?" - w is an Entity "class", w.DateType is "int", w.Id is "string".
public class TimeSlice
{
public string Id { get; set; }
public byte[] RowVersion { get; set; }
public string ModalityId { get; set; }
public int DateType { get; set; }
public DateTime AvailableDate { get; set; }
public string StartTime { get; set; }
public string EndTime { get; set; }
public int Duration { get; set; }
public int TimeSliceType { get; set; }
public int? MaxNumber { get; set; }
public int? MaxPercentage { get; set; }
public string Description { get; set; }
}

@dadhi dadhi self-assigned this Nov 21, 2017
@dadhi dadhi added the bug label Nov 21, 2017
@dadhi dadhi added this to the 1.5.1 milestone Nov 21, 2017
@dadhi
Copy link
Owner

dadhi commented Nov 21, 2017

Thanks for the info, I will get it from here.

dadhi added a commit that referenced this issue Nov 21, 2017
@dadhi
Copy link
Owner

dadhi commented Nov 21, 2017

Hi @OscarKoo ,

I have added the sample test here and it is working just fine with the latest source.

Did you check on the latest source or v1.5?

@OscarKoo
Copy link
Author

OscarKoo commented Nov 22, 2017

@dadhi
Yes, I used your latest source which you gave me in the last issue.

Since there is no vs2015 on my machine, so I have to download "msbuild 2015" to build your dll. (https://www.microsoft.com/en-us/download/details.aspx?id=48159)

And this Exception only happens on the testing server (not on my machine). and the testing server is windows server 2008 R2 (with .net framework 4.5.1), and my machine is windows7 (with .net framework 4.5.1).

I'm not sure whether this Execption only happens in my particular scenario, either the way I built the dll or the testing server environment...

If you can not find anything wrong, maybe I have to wait your new upcoming release and try again. Thanks for your investigation.

@dadhi dadhi modified the milestones: 1.5.1, 1.6.0 Dec 3, 2017
@dadhi dadhi closed this as completed Dec 3, 2017
@dadhi
Copy link
Owner

dadhi commented Dec 3, 2017

Check the v1.6 if it is still reproducible.

@OscarKoo
Copy link
Author

OscarKoo commented Dec 8, 2017

Same exception in v1.6...

System.InvalidProgramException: Common Language Runtime detected an invalid program.
at (Closure5 , TimeSlice ) at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext()
at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)

@dadhi
Copy link
Owner

dadhi commented Dec 8, 2017

Hi @OscarKoo,

Thanks for checking. I will try to reproduce.

@dadhi dadhi reopened this Dec 8, 2017
@dadhi
Copy link
Owner

dadhi commented Dec 8, 2017

@OscarKoo,

May I ask you to add the Test below with the sample Entity class into Test project with NUnit, targeting the same .net 4.5.1 and try to run it?

   [Test]
    public void Complex_expression_with_DateTime_Strings_and_Int()
    {
        var dtNow = DateTime.Now;
        var version = new Entity { DateType = 1, AvailableDate = dtNow };
        var startTime = "b"; // a <= b
        var endTime = "x"; // y >= x
        var timeSliceId = "42";

        Expression<Func<Entity, bool>> e = w =>
            w.DateType == version.DateType &&
            w.AvailableDate == version.AvailableDate &&
            string.Compare(w.StartTime, startTime) <= 0 &&
            string.Compare(w.EndTime, endTime) >= 0 &&
            w.Id != timeSliceId;

        var f = e.CompileFast(true);


        var tested = new Entity
        {
            DateType = 1, AvailableDate = dtNow,
            StartTime = "a", EndTime = "y"
        };
        Assert.IsTrue(f(tested));
    }

    public class Entity
    {
        public string Id { get; set; }
        public int  DateType { get; set; }
        public string StartTime { get; set; }
        public string EndTime { get; set; }
        public DateTime AvailableDate { get; set; }
    }

@dadhi dadhi closed this as completed Dec 8, 2017
@dadhi dadhi reopened this Dec 8, 2017
@dadhi
Copy link
Owner

dadhi commented Jul 24, 2018

Hi @OscarKoo,
I have released v1.9 which improves handling of ValueTypes, and may fix this issue. Is it possible for you to check?

@dadhi
Copy link
Owner

dadhi commented May 23, 2019

Outdated, closing.

@dadhi dadhi closed this as completed May 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants