notsupportedexception

NHibernate Overcoming NotSupportedException

血红的双手。 提交于 2019-12-04 05:35:35
Does anyone know of any way to overcome NotSupportedException? I have a method against a User: public virtual bool IsAbove(User otherUser) { return HeirarchyString.StartsWith(otherUser.HeirarchyString); } And I want to do: _session.Query<User>.Where(x => loggedInUser.IsAbove(x)); But this throws a NotSupportedException. The real pain though is that using _session.Query<User>.Where(x => loggedInUser.HeirarchyString.StartsWith(x.HeirarchyString)); works absolutely fine. I don't like this as a solution, however, because it means that if I change how the IsAbove method works, I have to remember

Automapper 3.0 - This type is not supported on this platform IMapperRegistry

我的梦境 提交于 2019-12-03 22:03:16
I updated my project to use Automapper 3.0.0 and now my TFS build is not succeeding. The error is the following: " ...System.PlatformNotSupportedException: System.PlatformNotSupportedException: This type is not supported on this platform IMapperRegistry. " Is there anyone that can help me resolve this issue. In the mean time, I am going to revert to previous version since that one seems to work fine. jni We had the same issue on our build server. MsTest seemed to remove DLLs it deemed unnecessary (note : this claim is only an educated guess). To fix it, add an explicit call to something in

try-with-resources are not supported at this language level - Android

こ雲淡風輕ζ 提交于 2019-12-03 09:38:53
I have a problem with "try-with-resources are not supported at this language level" in android in the following posted code, I tried to set language to 7 but it stills keeps giving me the same example plus it keeps giving me the option to change to language 7. public String ReadFile(String fileName) { try (BufferedReader br = new BufferedReader(new FileReader(fileName+".txt"))) { StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { sb.append(line); sb.append(System.lineSeparator()); line = br.readLine(); } String everything = sb.toString(); return

When to use InvalidOperationException or NotSupportedException?

跟風遠走 提交于 2019-12-03 08:09:12
问题 I am implementing a custom collection implementation that can either be readonly or non-readonly; that is, all the methods that change the collection call a function that is the moral equivalent of: private void ThrowIfReadOnly() { if (this.isReadOnly) throw new SomeException("Cannot modify a readonly collection."); } I am not sure which of NotSupportedException or InvalidOperationException I should use in that case. 回答1: The MSDN only has one bit of guidance on this precise topic, on

C#, Is there a better way to verify URL formatting than IsWellFormedUriString?

♀尐吖头ヾ 提交于 2019-12-03 06:19:07
Is there a better/more accurate/stricter method/way to find out if a URL is properly formatted? Using: bool IsGoodUrl = Uri.IsWellFormedUriString(url, UriKind.Absolute); Doesn't catch everything. If I type htttp://www.google.com and run that filter, it passes. Then I get a NotSupportedException later when calling WebRequest.Create . This bad url will also make it past the following code (which is the only other filter I could find): Uri nUrl = null; if (Uri.TryCreate(url, UriKind.Absolute, out nUrl)) { url = nUrl.ToString(); } Greg The reason Uri.IsWellFormedUriString("htttp://www.google.com",

When to use InvalidOperationException or NotSupportedException?

只愿长相守 提交于 2019-12-02 21:44:20
I am implementing a custom collection implementation that can either be readonly or non-readonly; that is, all the methods that change the collection call a function that is the moral equivalent of: private void ThrowIfReadOnly() { if (this.isReadOnly) throw new SomeException("Cannot modify a readonly collection."); } I am not sure which of NotSupportedException or InvalidOperationException I should use in that case. The MSDN only has one bit of guidance on this precise topic, on NotSupportedException : For scenarios where it is sometimes possible for the object to perform the requested

Stream.Length throws NotSupportedException

浪尽此生 提交于 2019-11-28 21:09:44
I am getting a error when attempting stream.Length on a Stream object sent into my WCF method. Unhandled Exception! Error ID: 0 Error Code: Unknown Is Warning: False Type: System.NotSupportedException Stack: at System.ServiceModel.Dispatcher.StreamFormatter.MessageBodyStream.get_Length() How do you get the length of the stream? any examples? Stream.Length only works on Stream implementations where seeking is available. You can usually check to see if Stream.CanSeek is true. Many streams, since they're being streamed , are of a nature where it's impossible to know the length in advance. If you

Stream.Length throws NotSupportedException

三世轮回 提交于 2019-11-27 13:31:52
问题 I am getting a error when attempting stream.Length on a Stream object sent into my WCF method. Unhandled Exception! Error ID: 0 Error Code: Unknown Is Warning: False Type: System.NotSupportedException Stack: at System.ServiceModel.Dispatcher.StreamFormatter.MessageBodyStream.get_Length() How do you get the length of the stream? any examples? 回答1: Stream.Length only works on Stream implementations where seeking is available. You can usually check to see if Stream.CanSeek is true. Many streams,

Create a BitmapImage from a byte array

心不动则不痛 提交于 2019-11-26 23:06:52
I am creating a byte array with arbitrary values in it and want to convert it into a BitmapImage. bi = new BitmapImage(); using (MemoryStream stream = new MemoryStream(data)) { try { bi.BeginInit(); bi.CacheOption = BitmapCacheOption.OnLoad; bi.StreamSource = stream; bi.DecodePixelWidth = width; bi.EndInit(); } catch (Exception ex) { return null; } } This code gives me a NotSupportedException all the time. How could I create a BitmapSource from any byte array? Given an array of bytes where each byte represents a pixel value, you may create a grayscale bitmap like shown below. You need to

Why does NotImplementedException exist?

自作多情 提交于 2019-11-26 18:13:44
This really, really urks me, so I hope that someone can give me a reasonable justification for why things are as they are. NotImplementedException. You are pulling my leg, right? No, I'm not going to take the cheap stab at this by saying, "hang on, the method is implemented - it throws a NotImplementedException." Yes, that's right, you have to implement the method to throw a NotImplementedException (unlike a pure virtual function call in C++ - now that makes sense!). While that's pretty damn funny, there is a more serious problem in my mind. I just wonder, in the presence of the