You searched for new guid. We found 22 results in 0.119 seconds.

Compiler Error : An expression tree may not contain a dynamic operation

Consider the following code, which wraps (rather than using inheritance for specific reasons) an instance of Dictionary<string, T> and implements IEnumerable and IQueryable...
Jon Skeet
people
quotationmark

The problem is that your type implements IQueryable<>, so the Queryable method is chosen by member lookup - so the compiler tries to create an expression tree from your lambda expression... and that's what fails. The dictionary... more

people

Linq statement return error when no record found

THe linq statement below return an exception error when no match record found. Is there anyway to handle this?, Please advise, thank you AdventureEntities hem = new...
Jon Skeet
people
quotationmark

No, that shouldn't throw an exception. It will, however, set list to null - because that's what FirstOrDefault does when there are no results. If you then dereference list, you'll get a NullReferenceException. You can avoid this by just... more

people

How to compare Lists of Guids in C#

I have got this structure var values = new Dictionary<int, List<Guid>>(); And I have to say if all dictionary elements has the same set of List<Guid>. I dont...
Jon Skeet
people
quotationmark

I'd create a HashSet<Guid> from one of the values (any) and then check that all of the others are equal to it: // TODO: Handle the dictionary being empty var firstSet = new HashSet<Guid>(values.First().Value); var allEqual =... more

people

Xamarin.Android JSON.Net serilization fails on 4.2.2 device only TimeZoneNotFound exception

I am using JSON.Net to serialize a DTO and I am getting the following exception on the physical device. THis works on all other devices we have tested on, but is failing on the...
Jon Skeet
people
quotationmark

Yes, TimeZoneInfo.Local is somewhat broken on Mono. I've seen three different failure modes here: Returning a time zone which acts correctly, but has an ID of "Local" Returning a null reference Throwing an exception I don't have a good... more

people

How to use inline method when assigning to object

With LINQ to objects is there a way to assign a property using an inline method without defining the method separately? For example, I have a list I am iterating over (results)...
Jon Skeet
people
quotationmark

If you're using LINQ to Objects, your lambda expression only needs to be convertible to a delegate. So you can use something like: var testObject = results.Select(row => { // Several statements here, as you wish int x = row.X; ... more

people

IEnumerable<T> Has Results Until Count() Or Any() Are Called

I'm performance testing variations on Linq extension methods, and I came across an odd situation. When execution returns to the test, calling Count() first will return 1, and...
Jon Skeet
people
quotationmark

Each time you iterate over the result, you're going to call that Where filter... which removes the items from hashset as it goes. So after it's iterated once, hashset will no longer have any of those items, so there'll be nothing left to... more

people

'system.argumentexception' When uploading multipart

I am trying to post multipart data using System.Net.Http.HttpClient but when I am instanciating my content I am getting this exception: A first chance exception of type...
Jon Skeet
people
quotationmark

# is invalid in a MIME boundary. From RFC 2046: The only mandatory global parameter for the "multipart" media type is the boundary parameter, which consists of 1 to 70 characters from a set of characters known to be very robust... more

people

Get random seed for generating unique password

I have written a simple module which generates passwords fulfilling my complexity requirements. Module PasswordGenerator Private ReadOnly _alphaChars As Char() =...
Jon Skeet
people
quotationmark

Don't use Random at all for something as sensitive as this. Use RNGCryptoServiceProvider instead, which provides reasonably secure seeding. It's not as simple an API to use as Random - you basically just get bytes, potentially guaranteed... more

people

Java class and return

I have a stupid question for you guys, since I get an error with this code. This is my first Stackoverflow post, so sorry if I did any mistakes. I want to return a boolean (true...
Jon Skeet
people
quotationmark

The problem is that if an exception is thrown, you catch it and then drop to the end of the method without returning a value. What do you want the caller to see at that point? I suspect you either want to let the exception propagate up... more

people

UserManager.CreateAsync(user, password) stuck in infinite loop

I'm trying to make a very simple implementation of an IUserStore that would essentially: use NHibernate save users in a single table (no claims/logins) store role names in the...
Jon Skeet
people
quotationmark

Your approach to async is fundamentally broken at the moment, because you're returning the same task for all operations... and never starting it. I don't see any "infinite loop" here - I just see you blocking on a task which can never... more

people