w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Scala Type Mismatch underlying type and class vs method
The problem in your code is type parameter shadowing. You have: class ThreeStacks[A, B, C](val stackSize:Int = 1000) { def push1[A](value: A): Unit = stack1.push(value) ... } It should be: class ThreeStacks[A, B, C](val stackSize:Int = 1000) { def push1(value: A): Unit = stack1.push(value) ... } The way you have done it, type parameter A of class ThreeStacks and type parameter A of method push1 are completely different ones and thus, are incompatible with each other. The same applies to B and C.

Categories : Scala

Warning: unchecked call to compareTo(T) as a member of the raw type java.lang.Comparable
The signature on your method uses the raw Comparable interface without the generic. There appears to be a requirement in your set implementation that the data types implement Comparable, so since you're now using generics, you should make the change comprehensively. You didn't post the class declaration for SimpleSet, so the Comparable restriction on E may already be there. If not, you need to change your class declaration to: public class MySet<E extends Comparable<? super E>> implements SimpleSet<E> This tells clients of your class that only types implementing Comparable are permitted as generic type parameters for your set implementation. You didn't post the code for BTNode, but it probably needs to be parameterized on E as well (BTNode<E>). Now, since you'

Categories : Java

Underlying provider failed in connectionstring
If you have not modified your connection string it's incorrect. <someip> isn't valid. Otherwise try to open the connection manually and see what error you get: var conStr = "data source=<SomeIP>;attachdbfilename=|DataDirectory|databse.mdf;integrated security=True;MultipleActiveResultSets=True;Trusted_Connection=True;"; var connection = new SqlConnection(conStr); connection.Open();

Categories : C#

The underlying provider failed on Open. MVC
Try something along these lines. <add name="LeaveMSContext" connectionString="Data Source=*******SQLEXPRESS; Initial Catalog=NAMEOFYOURDATABASE; Integrated Security=True; AttachDbFilename=|DataDirectory|DATABASEFILE.mdf MultipleActiveResultSets=True; " providerName="System.Data.SqlClient"/>

Categories : C#

The underlying provider failed on Open exception in wcf in iis7
Need your confirmation...., You use mdf file in your connection string, where is your IIS server, is it on same machine where you ran app with Visual Studio.? If you host on different physical box then full path exist with .mdf file..... Below is portion of connection string from your shared web.config, you should verify the exitance of file first..... data source=(localDB)v11.0;attachdbfilename=C:UsersinesDocumentsVisual Studio 2012ProjectsGestionDeComptabiliteDataRepositoryApp_DataGestionComptabilite.mdf;MultipleActiveResultSets=True;App=EntityFramework"

Categories : C#

Entity Framework The underlying provider failed on Open
Please check the following things first. While generating the Edmx you would have given a name to you connection string. that gets into the app config of the project with the Entity. Have you copied the same connection string to your main Config file. Also the Name should be same as which you have given while generating the EDMX file.

Categories : C#

The underlying provider failed on Open in entity framework connection
I don't know why you get this error but I use this connection string and I don't have any problem. remember the name of the DbContext class and connection string should be same <add name="MyDB" connectionString="Server=127.0.0.1;User ID=sa;Password=password;Database=Database" providerName="System.Data.SqlClient"/>

Categories : C#

Best way to handle Underlying Provider Failed to Open Internet Dropout
For EF5 you can take a look at SQL Azure and Entity Framework Connection Fault Handling for some ideas . EF6 has a new feature - Connection Resiliency which allows database operations to be re-tried if the connection is lost. See this for more details.

Categories : Entity Framework

Why I cant call method from other class when implementing custom authentication provider
From your description it seems that method simpleService.doNothing() never returns, thus causing your thread to get stuck, that is why the other code in your authenticate() method isn't reached. And by the way, a simple test with the debugger should reveal the problem easily. Edit: Since I understand debugging is not an option here, the way to go is to print to log before calling the method, inside the method and after the method. Since you've done it and the method doesn't print, there are now 2 options: simpleReceiver is null, a simple try catch with logs should reveal it. simpleReceiver is not of type SimpleReceiver but a derived class that does infinite long work in its function, if that is the case a simple log print of the instance type should reveal it.

Categories : Java

How do I call a method from a UIbutton selector?
When the selector you add to the button is called, the button itself will be passed as the first argument if the selector allows for one. In order to get a reference to your image, you would either need to do this (assuming the image you want is the background image for the button): - (void)displayEditorForImage:(UIButton*)sender { UIImage* imageToEdit = [sender backgroundImageForState:UIControlStateNormal]; AFPhotoEditorController *editorController = [[AFPhotoEditorController alloc] initWithImage:imageToEdit]; [editorController setDelegate:self]; [self presentViewController:editorController animated:YES completion:nil]; } Or you would need to make a custom UIButton that has an extra property for the associated image, and then just access the image through the button i

Categories : Iphone

Inferred type is not a valid substitute for a Comparable generic type
Actually more detailed explanation of this error gives your javac itself: java: no suitable method found for sort(java.util.ArrayList<MyItem<V>>) method java.util.Collections.<T>sort(java.util.List<T>,java.util.Comparator<? super T>) is not applicable (cannot instantiate from arguments because actual and formal argument lists differ in length) method java.util.Collections.<T>sort(java.util.List<T>) is not applicable (inferred type does not conform to declared bound(s) inferred: MyItem<V> bound(s): java.lang.Comparable<? super MyItem<V>>) So, the main question is: why is method Collections.<T>sort(java.util.List<T>)) not applicable? The answer is: because in Collections.<T>sort(java.util.List<

Categories : Java

Scala type mismatch: default.type (with underlying type A1 => B1)
Strange, as soon as I renamed default variable, everything compiled fine: scala> def composeHandlingFuture[T](fut: Future[T], x: T): Future[T] = | fut recover { case e: Exception => x } composeHandlingFuture: [T](fut: scala.concurrent.Future[T], x: T)scala.concurrent.Future[T]

Categories : Scala

Does a variable of an interface type act as value type if the underlying implementation is a struct?
No, interface is a contract, to make it work properly you need to use ref keyword. public void SetInterfaceProp(ref IMyInterface thingy) { thingy.desc = "the implementing type is a struct"; } What matters here is a real type that stays inside that interface wrap. To be more clear: even if code with method SetInterfaceProp defined like public void SetInterfaceProp(IMyInterface thingy) { thingy.desc = "the implementing type is a struct"; } will work: IMyInterface inter= default(MyStruct); SetInterfaceProp(inter); this one will not : MyStruct inter = default(MyStruct); SetInterfaceProp(inter); You can not gurantee that the caller of your method will always use IMyInterface, so to guarantee expected behavior, in this case, you can define ref keyword, that will guaran

Categories : C#

"The underlying provider failed on Open" Error when using EF5 Code First with Unity IoC in Azure Worker Role against SQL Azure
Thanks to Arthur Vickers who commented on my question, I'll go ahead and chalk this on up to transient errors due to Azure SQL Database connectivity. I was never able to fully prove this, however, I brought up a SQL VM on Azure and created my DB there then changed my cloud service app to point to that DB instead. Been monitoring the logs, and haven't seen the same issues yet... One potential option, if I return to Azure SQL Db is to roll my own retry logic using Transient Fault Handling block from Microsoft P&P, or use a project like Rob Moore's ReliableDbProvider (https://github.com/robdmoore/ReliableDbProvider). When EF6 comes out, I'll look into using the built in capabilities for transient errors. Hope this helps someone else.

Categories : Entity Framework

MVC local dev The underlying provider failed on open - Login failed for user 'NT AUTHORITYANONYMOUS LOGON' in Firefox only
While most solutions to this indicated that you needed to set or add Integrated Security=True; to the connection string among other possible solutions. I first found that if I set impersonate to true and passed in my own domain username and password that it fixed it but this was a bad solution as it required me to store my details. The actual solution which solved this particular problem with least possible issues was to set impersonate to false and bam no further issues.

Categories : Sql Server

How to convert nullable type to its underlying type?
But it supports nullable types, AllowDbNull is true by default: var table = new DataTable(); table.Columns.Add("NullableInt", typeof(int)); table.Rows.Add(1); table.Rows.Add(2); table.Rows.Add(3); table.Rows.Add((int?)null); Use the DataRow extension methods which support nullable types, for example: foreach(DataRow row in table.Rows) { int? value = row.Field<Int32?>("NullableInt"); // modify the value with SetField: row.SetField<Int32?>("NullableInt", null); // or: row.SetField("NullableInt", (int?)null); }

Categories : Dotnet

Why does T extends Comparable include T? Meaning includes Comparable?
From Lower Bounded Wildcards, a section of the Generics section of The Java Tutorial: ... a lower bounded wildcard restricts the unknown type to be a specific type or a super type of that type. (bold mine, emphasis theirs) Thus, the set of classes that match T extends Comparable<T> is a subset of the set of classes that match T extends Comparable<? super T>. The wildcard ? super T itself matches T and any superclasses of T. In other words, the assumption that "super would only include super class items" is simply incorrect. Your confusion in the example may also arise from the fact that JTextField is a superclass of JPasswordField; in other words, JPasswordField extends JTextField. The example would match any of the following classes: javax.swing.JPasswordField javax

Categories : Java

Call store procedure from dapper which accept list of user defined table type
My problem is also that I have cars in generic list List Cars and I want pass this list to store procedure. It exist elegant way how to do it ? You need to convert your generic list Car to a datatable and then pass it to storedprocedure. A point to note is that the order of your fields must be same as defined in the user defined table type in database. Otherwise data will not save properly. And it must have same number of columns as well. I use this method to convert List to DataTable. You can call it like yourList.ToDataTable() public static DataTable ToDataTable<T>(this List<T> iList) { DataTable dataTable = new DataTable(); PropertyDescriptorCollection propertyDescriptorCollection = TypeDescriptor.GetProperties(typeof(T)); for

Categories : C#

How can I get type information about a type created using the type provider framework
At runtime, STable isn't a real .NET type - it's erased down to some other type (obj in this case) - this is just how (erasing) type providers work. If you absolutely need to get the type programmatically, then it's possible to do it using the raw type provider API, but this will be pretty ugly. To do this, get an instance of the ITypeProvider (just like the compiler does behind the scenes), and then navigate the resulting namespaces and types until you get the System.Type instance you're looking for.

Categories : F#

Why Comparable natural ordering needs to be consistent with equals method?
Short answer: whenever compareTo(a,b) returns 0 for two objects a and b, a.equals(b) and b.equals(a) should be true, and vice versa. Long answer: as stated in the Comparable documentation, implementations of Comparable enforce a total ordering. One of the properties of total ordering is "antisymmetry": if we define a total ordering ≤, then: If a ≤ b and b ≤ a then a = b This is represented as the 0 return value of compareTo(). This trait is exploited by the methods and classes mentioned in the text you quoted for more correct and efficient behavior.

Categories : Java

How to call a method of a parameterized type?
You've declared your generic type parameter Type, but it could be anything, not just a foo, such as a String. Restrict type with an upper bound so that you know it's some kind of foo: public static <Type extends foo> void invoke_baz( Type object ) Alternatively, just ask for a foo in your argument, removing any need for generics: public static void invoke_baz(Foo object)

Categories : Java

How to call a method with List type
List is a generic type, which means that it must include type parameter T: List<T> e.g. List<int> or List<YourClass>

Categories : C#

java reflection to invoke a method that takes a Comparable[] argument
When you call Method.invoke with this signature: public Object invoke(Object obj, Object... args) ... the varargs parameter is only used as a varargs parameter when it would fail otherwise. So this call: m2.invoke(null, "jon"); is equivalent to: m2.invoke(null, new Object[] {"jon"}); But String[] is implicitly convertible to Object[], so this call: m1.invoke(null, a); is not expanded to wrap a in an Object[]. It's trying to call the method as if it's got 7 string parameters rather than one array parameter. Two options: Declare a as type Object rather than String[], which will then make the compiler perform the wrapping for you. Explicitly wrap it in an array: m1.invoke(null, new Object[] { a }); Either should be fine.

Categories : Java

Do I need a equals and Hashcode method if my class implements comparable in Java?
The article you brough is talking on TreeSet. a tree set is a tree with each node has a place defined by it's value in compare to the other values already in the tree. a hashTable stores key/value pairs in a hash table. When using a Hashtable, you specify an object that is used as a key, and the value that you want linked to that key. The key is then hashed, and the resulting hash code is used as the index at which the value is stored within the table. the difference between Hashable and TreeSet is that treeset don't need hashCode, it just need to know if you need the take the item left or right in the tree. for that you can use Compare and nothing more. in hashTable a compare will suffice, because it's build differently, each object get to his cell by hashing it, not by comparing it to

Categories : Java

Deferred type inference on method call
Indeed, this can seems unintuitive. The reason is that sort1 defines no constraints on O, so 'ord: O' is ambiguous. (the constraint on the first implicit parameter only defines a constraint on 'ev' type). Hope it helps :)

Categories : Scala

Call method of unknown class type
I think you may have some general design issues, but your compile error is due to a missing parenthesis. return ((Commands)type).execute(cmdParams); Dot is higher presence (happens before) than casting. With full quotations yours looks like the following: return (Commands)(type.execute(cmdParams)); Which fails since it cannot find execute given what it knows about type. Also note that you may want to look into why you are looking at the type name, as and is are safer and easier to implement. var command = type as Commands; if (command != null) { return command.execute(cmdParams); } else { //Command not found! return 1; }

Categories : C#

Is there a principled way to compose two monad transformers if they are of different type, but their underlying monad is of the same type?
Yes. Combine hoist from the mmorph package with lift to do this: bound :: (MonadTrans t, MonadTrans s, MFunctor t, Monad m) => t m () -> s m () -> t (s m) () bound master slave = do hoist lift master lift slave To understand why this works, study the type of hoist: hoist :: (MFunctor t) => (forall x . m x -> n x) -> t m r -> t n r hoist lets you modify the base monad of any monad transformer that implements MFunctor (which is most of them). What the code for bound does is have the two monad transformers agree on a final target monad, which in this case is t (s m). The order in which you nest t and s is up to you, so I just assumed that you wanted t on the outside. Then it's just a matter of using various combinations of hoist and lift to get t

Categories : Haskell

No mapping exists from object type System.Net.Sockets.SocketException to a known managed provider native type
I got the answer to this problem. It was actually occurring due to improper datatype conversion at the SQL Server end. By mistake i was passing ex.innerException into a field of datatype nvarchar. This is why the exception was occurring. Hence the final point here is: if you try to pass some parameter from any language to SQL server, you must make sure that the datatypes are matching or interoprable with each other.

Categories : C#

What is the type of the underlying stream of a boost::iostreams::filtering_stream?
It's not real, since not istream will be pushed into filtering_stream (for my boost 1.48 it will be boost::iostreams::detail::mode_adapter<boost::iostreams::input, std::istream> for example), you can check it type by component_type function. However, I have no ideas, why you need to get stream from filtering_stream, since you send reference - you should have this object in places, where you use this filtering_stream. Also, you can use reference_wrapper for this case (i.e push(boost::ref(in));) and then get it by component using auto ptr = component<boost::reference_wrapper<std::istream>>(1);

Categories : C++

how to get the i-th underlying type (by an const integer) of af boost::variant
The variant contains an MPL sequence called types, which you can use to access the types. #include <boost/mpl/at.hpp> typedef typename boost::mpl::at_c<VType::types, 0>::type TYPE1;

Categories : C++

causes all buttons to call the same method
I don't know what you expect the preRenderView event to do, but it will always be called before the RENDER_VIEW phase (hence the name). You clicking the buttons will cause the view to be re-rendered, hence the method will be called always when you click a button. If you used ajax and only rendered small parts of the view, the event would not be triggered. If you don't want to call that method every time the view is rendered, you could try a ViewScoped bean and a @PostConstruct method.

Categories : Java

Method/function return type in call stack
I got it by myself. First question: 1) How will you modify this attached image to specify the return type and why? Answer: There is no point of return type in call stack. In many languages you don't even specify return type, like python, PHP etc. So there is no relation of return type with call stack. 2nd question: 2) I can not specify more than one return type in any language (that i know), why? Answer: It depends on requirement. Language designer don't feel any need to return more than one value (Off course they provide alternate like returning array, but value returned only one, that is reference to array). If language designers feel the need to return two values, I think they can. But there is no need of that.

Categories : Function

Java determines which method to call using a generic type argument?
What happens here is that the compiler can distinguish the two constructors by using generics, so it does before creating the byte code and before stripping generics. In the middle case, it will tell the VM to invoke MyClass2<init>(Collection) (i.e. generate byte code which matches this specific constructor). The VM doesn't try to determine which method matches at runtime. That would be way too slow. Instead, it relies on the compiler creating very specific instructions. This is why the code above works even though the generic information has been erased at runtime. [EDIT] To clarify: The byte code contains additional information which the compiler can see and use. You can get the same information via reflection. Erasure means that the byte code interpreter and JIT doesn't care

Categories : Java

Bind button click to method on underlying datasource
Using MvvmLight RelayCommand: ViewModel: private ICommand _runTestCommand; public ICommand RunTestCommand() { return _runTestCommand ?? (_runTestCommand = new RelayCommand(RunTest)); } XAML: <Button x:Name="btnRunTest" Command="{Binding Path=RunTestCommand}"> Run Test </Button> See Also : How can I use the RelayCommand in wpf?

Categories : C#

Mock a method call with void return type using JMockit or Mockito
I was not sure what the Holder interface looked like so I made some assumptions. But, this is how you mock a method with a void return type using Mockito: @SuppressWarnings("unchecked") @Test public final void test() { // given final String expectedStatus = "status"; final String expectedMessage = "message"; final MyPort mockPort = mock(MyPort.class); final Answer<Void> registerAnswer = new Answer<Void>() { // actual parameter type doesn't matter because it's a void method public Void answer(final InvocationOnMock invocation) throws Throwable { // Here I'm stubbing out the behaviour of registerService final Object[] arguments = invocation.getArguments(); // I don't actually care about these, but if you wanted the

Categories : Unit Testing

Call proper subclass method after previous cast to superclass type
Why isn't the method defined in BC? This is what polymorphism is all about. Your other option is to have the objects implement an interface that contains m and have a collection of that interface instead of BC. Or use reflection (ew), or check the type (ew).

Categories : Java

Why does JQuery NOT selector failed on Type Submit but works on Type Button
Your code does work, here: http://jsfiddle.net/AstDerek/s5cyk/ What do you expect to happen with the code you are using? Original answer: I don't really understand what your code does, but it seems you are trying to target a button with an :input selector, so your code doesn't work as you expect. Maybe this selector can do the job: $('#myForm :input:not(#btnSubmit), #myForm button:not(#btnSubmit)')

Categories : Javascript

Create generic groupBy method
You need to define <T> at the beginning. Check the official tutorial for more information private <T> Map<String, List<T>> groupBy(List<T> list, String fieldName) { }

Categories : Java

Checking to ensure at least one call has been made prior to executing - This method must return a result of type int
Its kind of hard to read the way its formatted but it looks like this method is the problem public int onStartCommand(Intent intent, int flags, int startId, int state, it looks like the return statement is in the wrong part. Move it after the next bracket. This return startId; } } to this } return startId; } You should try to format your code a little better when you post but it looks like it might be inside of an else so it may never be reached. If you only want it to return startId if some condition is met then you can leave it how it is but put a default return statement to return some int if the condition isn't met

Categories : Java

Casting between an object of generic type "T" and an object of generic type ">"
Based on the exception, it looks like you're initializing element with new Object[someLength] and doing an unchecked cast to T[]. This is likely happening in ArrayLinearList. The problem is that in this code: element[ pedro ] = maria; element is treated as a Comparable[] at runtime, and an Object[] isn't a Comparable[]. There are many existing posts related to generic array creation, but your issue is interesting because you've thrown inheritance into the mix (with a narrowing of a type parameter's bounds). The best solution seems to be only interacting with element within the ArrayLinearList class. Make it private and expose getters and setters. This should avoid runtime failures like this (which take some thought to avoid when doing unchecked casts like (T[])new Object[someLength]).

Categories : Java



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.