I saw the question posed here: Have I implemented Equals()/GetHashCode() correctly? but my c# is not as strong, and I am unfimiliar with IEquatable enough that I would like to see this in VB.NET if possible please.My example code (The class will eventually use INotifyPropertyChanged when I get there):[code]
I've implemented the Event Based Async Pattern for the first time in a relatively complex class. I'm having some doubts about if I've done it as it should be done, and if there are no better approaches. One of the things that make me frown the most is how I'm currently handling all the cross thread events. This class contains a decent amount of events, about 20. What I've done is created a dictionary in which I have a list of callbacks, one for each event. The keys are a value of an enum containing all keys I created. In the underneath line, eventDelegates is the dictionary, and delegates is the enum.
I'm seeing a strange build bug a lot. Sometimes after typing some code we receive the following build error.
Class 'clsX' must implement 'Event PropertyChanged(sender As Object, e As PropertyChangedEventArgs)' for interface System.ComponentModel.INotifyPropertyChanged'.
And
'PropertyChanged' cannot implement 'PropertyChanged' because there is no matching event on interface 'System.ComponentModel.INotifyPropertyChanged'.
Those error should never go together! Usually we can just ignore the exception and build the solution but often enough this bug stops our build. (this happens a lot using Edit and Continue which is annoying)Removing the PropertyChanged event and retyping the same code! sometimes fixes this.We're using a code generator that causes this error to surface but just editing some files manually triggers this exception too. This error occur's on multiple machines using various setups.
I have several entities I need to make IEquatable(Of TEntity) respectively. I want them first to check equality between EntityId, then if both are zero, should check regarding to other properties, for example same contact names, same phone number etc. How is this done?
I found the line in a program that references UrlNormalizerUtil.UrlNormalizer to validate a url. It calls it from a GeneralPurposeUtilities file which is added to the project properties in references as a .dll file.
My question is: where does this file come from? Is is self coded or from some library? how else can the UrlNormalizer be implemented?
I have an Entity class which Implements IWeightable:
Public Interface IWeightable Property WeightState As WeightState End Interface
I have a WeightCalculator class:
Public Class WeightsCalculator Public Sub New(...) .. End Sub
Why can I not do wc.Calculate(entities)? I receive:
Unable to cast object of type 'System.Collections.Generic.List1[mynameSpace.Entity]' to type 'System.Collections.Generic.IList1[myNamespace.IWeightable]'.
If Entity implements IWeightable why is this not possible?
I've boxed in red. The class displayed here does implement INotifyPropertyChanged, but the VB compiler seems to think that the PropertyChanged event as declared does not match the signature of INotifyPropertyChanged.PropertyChanged.Here I've selected the offending line of code. Between this and the next screenshot I literally just cut and paste the exact same line back into the file (i.e., I hit Ctrl + X followed by Ctrl + V).I have this happen sometimes, particularly with the INotifyPropertyChanged interface in my experience but I have no idea if the problem is limited to that single interface (which would seem bizarre) or not.Let's say I have some code set up like this. There's an interface with a single event. A class implements that interface. It includes the event. [code] Every now and then, when I build my project, the compiler will suddenly start acting like the above code is broken. It will report that the Person class does not implement INotifyPropertyChanged because it doesn't have a PropertyChanged event; or it will say the PropertyChanged event can't implement INotifyPropertyChanged.PropertyChanged because their signatures don't match.This is weird enough as it is, but here's the weirdest part: if I just cut out the line starting with Event PropertyChanged and then paste it back in, the error goes away. The project builds.
I am programming an ordering site in VB.Net and ASP.Net.I start with the main ordering form and the idea is that the user will select a subject from the drop down list and then click a button to retrieve all modules associated with that subject in a second form (smaller than the main order form).I have created the second form (frm2) and added content to it.In the main form inside the method which represents the button being clicked, I have coded the following:
Dim frm As New frm2() frm.show()
I then get an error that show has not been declared and so I create a method stub for it.I run the program and when I click on the button I get the following error:'method or operation is not implemented.'This points to the following line in the 2nd form:
Sub show() Throw New NotImplementedException End Sub
what I need to put inside this method to make my second form load when the button is clicked?
I recently finished a class that we're using to tie Access to some WCF Services. Of course this means that the .Net classes (and all of their properties) need to be visible to COM. Given that I'm using VB10 and the Contact class has about 20 properties I went ahead and used auto-implementing properties.Much to my surprise, the properties were not accessible from within VBA in Access. I tried marking the properties as ComVisible (which I didn't have to do in the past with standard properties) and it still didn't work. After changing the auto properties to standard properties everything worked.
VB.NET .NET 3.5 I have an aggregate class called Package as part of a shipping system. Package contains another class, BoxType . BoxType contains information about the box used to ship the package, such as length, width, etc. of the Box.
Package has a method called GetShippingRates. This method calls a separate helper class, ShipRater, and passes the Package itself as an argument. ShipRater examines the Package as well as the BoxType, and returns a list of possible shipping rates/methods.
What I would like to do is construct an Interface, IRateable, that would be supplied to the helper class ShipRater. So instead of:
[Code]...
However, ShipRater requires information from both the Package and its aggregate, BoxType. If I write an interface IRateable, then how can I use the BoxType properties to implement part of the Interface?
how ListView pointer is stored/removed at ReadOnly Property ListView in ListViewItem? How is it implemented? I know ListViewItems are stored in ListViewItemCollection which has constructor New(owner as ListView) but I dont know how pointer to ListView is add/remove in ReadOnly Property in ListViewItem...
a debate has been sparked here about the use of the strategy pattern in my classes. Basically, I have a 'Shape' object that is an interface 'IShape'. We have 'Circle', 'Rectangle' and 'Elongated' that are the concrete classes that must implement the IShape interface.
I have a base class which must be overriden. This base class sits in one dll shared by all. The derived classes will each be in their own dll such that the addition of a new derived class can be done by distributing a new dll. The set of dlls, and therefore the set of derived classes, will be discovered by the main program on startup. That's all pretty straightforward. The problem is that the main program needs to be able to query a database to figure out which type of derived class it needs, then create a class of that type. Naturally, it can't know which types will be available ahead of time because even I don't know that. The program has to be dynamically extensible.The obvious way to do this is to have an interface in the dll that is implemented by a class with a default constructor. The sole purpose of that class would be to return an object of the type (one of the derived types) defined in that dll. The derived types can't really be this class, because they can't have a default constructor since the base class doesn't have a default constructor, and the derived class can't make up the arguments that the base class constructor needs.
So basically, each dll that houses a derived class would also house a simple class that implemented an interface for the sole purpose of creating that particular derived class. The main program would examine the dll to find a class that implemented the interface, and once it found one, it could ask it what type of class it created, or it could ask it to create an instance of that class. It seems like there ought to be an easier way to dynamically add new classes to the project. It seems like the derived class ought to be able to tell the main project what type it was. This could be done, except that the derived class would have to exist before any of its methods could be called unless the methods were shared. Since you can't have a shared method in an interface, the interface itself would make no sense at that point, in which case I would need to discover whether the class in the dll derived from the base class in the second dll, just to figure out whether or not I wanted to create it. That's getting convoluted by now, so I guess I'll leave it there. The basic point is that the base class is known to the main program from a common dll. The number and types of derived classes can't be known at this time, so the program has to be able to discover them dynamically. Each derived class will sit in its own dll (or there could be more than one in a dll), and has to be discovered, and instances created, as needed, by the main program.
I am working on an ASP.NET project where I use VB.NET within Visual Studio 2010. Some of the other developers on the project are using Visual Studio 2008. We all check our code into single SVN repository. I would like to start using Auto-Implemented Properties within VB.NET ...
Property FirstName as String instead of ... Private FirstName as String
[code].....
My concern is that this could mess up things for those using VS2008. What would happen if someone using VS2008 needed to modify my class that made use of Auto-Implemented Properties? I am assuming that since everything compiles down to IL code then there would be no issue in binary compatibility. Though a problem would arise when editing source.
I have somehow managed to disable auto-implemented properties in my VS2010 IDE how to turn it back on. Almost every article on the internet loves to explain auto-implemented properties but doesnt give you the crucial option of how to turn it on or off.
As the subject describes, once I implemented support for DragDrop - The DoubleClick event of the ListView control no longer fires.An overview of the code is as follows:
Private Sub ListView_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView.MouseMove
I have a class that exposes an auto implemented property Enabled
[Code]...
But If I had not use an auto implemented property and declared my own backing-field as follows this is accessible from the subclass: Private _Enabled as Boolean ---- EDIT ---- The abve line is incorrect - this is not possible, it was in fact Protected in the original code which allowed access from the sub class See @JonSkeet answer ---- EDIT Of course I can just access Enabled from the sub class to work around this but can someone explain why this is the behaviour?
I have two forms, a main display form with a Zedgraph Pane on it and a second form with a single ComboBox control, opened by a button click on the first form and having its ComboBox filled by the Labels of the curves currently being shown by the Zedgraph pane.The code below seeks to remove the curve selected in the ComboBox by clearing its points, but on the CurveList.Clear line, I always get a "Method not Implemented" error.
Private Sub rmvCurve(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chnlSelectRmv.SelectedIndexChanged Dim curLabel As String
I am new to Visual Basic 2008 and NET and am using the Visual Studio 2008 Express editions. I recently downloaded the ebook "Build a Program Now!" for VB and have been working through it without problem until te end of the penultimate chapter 8.
Part of the exercise includes the following code:
Private Sub tsbFilterByMake_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsbFilterByMake.Click Dim filteredByMake = From Listing In Me.CarTrackerDataSet.Listing _
[CODE].........
Whenever I attempt to execute this code, I get the error "The method or operation is not implemented" on the last line before the End Sub. This suprised me because when I typed in the f after the = sign, Intellisense offered me the single choice of the required filteredByMake, suggesting to me (in my probable naivety) that it recognised it as a syntactically corrrect choice. This is not down to an error on my part somewhere in attempting the exercise as I get the same result trying to run the Complete code solution that accompanies the book. I have successfully replaced this and a similar Sub with SQL queries on the datasets in question, why the above code does not work and what can be done to correct it.
How should I correctly use CancelEventAgrs/CancelEventHandler?Does checking e.Cancel will return always the "right" result, even if the event eventually could consume some time?
Class Foo Public Event Deleting As System.ComponentModel.CancelEventHandler Private myObjectsToDelete As List(Of Object)
I don't have access to VB.NET right now so I can't test this value:Dim lst As New List(Of String)(cookieValue.Split("$"c))i got this from another question , but was wondering if A. The list will populate correctly and B. What does the c represent?
Im struggling with gettings the values from the correct strings.txt in my resource files in my in folder when switching languages. I have a [URL] (for English) and a domain.nl (for Dutch). It however doesnt seem to matter which domain I use and how I set the currentUICulture, the language shown to the user is always the same!