Moq's VerifySet Be Called - "Expression Is Not A Property Setter Invocation"?

Apr 10, 2010

I am trying to test that a property has been set but when I write this as a unit test: moqFeed.VerifySet(Function(m) m.RowAdded = "Row Added") moq complains that "Expression is not a property setter invocation" My complete code is

[Code]...

View 1 Replies


ADVERTISEMENT

.net - If An Interface Defines A ReadOnly Property, How Can An Implementer Provide The Setter To This Property

Jun 10, 2011

Is there a way for implementers of an interface where a ReadOnly property is defined to make it a complete Read/Write Property ?

Imagine I define an interface to provide a ReadOnly Property (i.e., just a getter for a given value) :

Interface SomeInterface
'the interface only say that implementers must provide a value for reading
ReadOnly Property PublicProperty As String
End Interface

This means implementers must commit to providing a value. But I would like a given implementer to also allow setting that value. In my head, this would mean providing the Property's setter as part of the implementation, doing something like this :

Public Property PublicProperty As String Implements SomeInterface.PublicProperty
Get
Return _myProperty

[code]....

View 5 Replies

Reflection - Find From A Property Info Object If That Property Has A Non Public (Private / Protected) Setter?

Aug 27, 2009

I searched on the forum / Internet for the solution how a PropetryInfo object (of a Public property) can reveal if it has a Private Protected Setter ... it was all in vain .... all help I found was about how to "Set" value of a public property having a Private Setter.I would like to know if I have a PropertyInfo object of a public property, how would I know if its Setter is Non Public?

I tried, in a exception handling block, where I did a GetValue of the PropertyInfo object and then called SetValue by setting the same value back... but to my surprise it worked well and didn error out.

[Code]...

View 1 Replies

Setter Value - How To Update Flag Property Of Row

Nov 10, 2009

I've got 2 classes, one called row and one called value. The row class has an array of value as one of its properties. The row class also has a property called flag which will contain an enum for how it has changed. On the setter for value I was hoping to update the flag property of row, but I cant work out how to do it via modern OO. Here's the

Public Class Row
'Variables
Private values_local() As Value
Private flag_local As DataFlags
'Properties
Property values() As Value() .....

View 1 Replies

Create Property Setter Delegate Via DynamicMethod?

May 28, 2010

I'm building an abstract class that handles some common operations for all of my data access objects. The class will utilize generics, so I can't make direct calls to constructors, business object properties, etc. Reflection is way too slow for what I want to accomplish, so I am using a DynamicMethod, ILGenerator, and Delegate caching instead (sample will follow).

The method I'm currently working on is a Private Shared method that populates a list of business objects using records from a data table. I'm having a problem building the property setter via IL. I'm getting an object reference error, but I'm not sure how to fix it. I believe the error comes from the "target" being Nothing, but the parameter I'm passing as the target is not Nothing at the time of invocation. Here are some snippets of what I've got so far:

'class declaration -- TList is strongly-typed list of T
Public MustInherit Class DataAccessBase(Of T, TList)
...
'delegate declaration

[code]...

I'm assuming the obj is not being passed correctly as the target, thus causing the target to be Nothing.

View 4 Replies

Dynamic Property Setter With Linq Expressions?

Jan 5, 2011

I want to create a simple function that does the following:

Sub SetValue(Of TInstance As Class, TProperty)(
ByVal instance As TInstance,
ByVal [property] As Expression(Of Func(Of TInstance, TProperty)),

[code].....

View 1 Replies

Nhibernate Projection List - Could Not Find Setter For Property

May 23, 2011

I have issue with a Nhibernate projection list, It keeps saying it Could not find a setter for property 'Commname' in class 'Label6.Domain.Product' or could not resolve property "pl.commname"
the property "commname" is a part of the object productslangs.

My product object looks like this:
Public Overridable Property Latinname() As System.String
Get
Return _Latinname
End Get
Set(ByVal value As System.String)
[Code] .....

View 1 Replies

Properties - Default Property Set Being Called Mysteriously Called?

Apr 2, 2012

I have the following line of code in my program:

JCL_History.Enqueue(JCL_History(I))


This JCL_History object is basically a Generic.List encapsulated in a wrapper and has the following method:

Public Sub Enqueue(ByRef value As String)
If Members.Contains(value) Then
Me.RemoveAt(Members.IndexOf(value))

[Code].....

In my testing I have 2 items in this JCL_History list. When I call that first line of code I posted (the one that invokes Enqueue) with I = 1 I expect the first item to be shuffled to the bottom and the second item to be shuffled to the top.

After the thread returns from Enqueue I notice that this is exactly what happens to my list, HOWEVER if I hit the "step_in" button after the execution of Enqueue I go into the Default Property's set method where Index = 1 and value = and it screws everything up, because the item that got shuffled to the end (index 1) gets overwritten by the item value shuffled to the top.

So basically the set method on the default property is getting called at what I think to be a completely ridiculous time. What gives? By the way I'm running VS2005 on XP.

View 1 Replies

Debugging Exception On Invocation Target Instead Of Invocation Caller?

Jan 28, 2010

When a delegate method throws an unhandled exception, that exception is usually trapped at the level of invocation (eg. Delegate.Invoke()) - you get a System.Reflection.TargetInvocationException...

However, when debugging classes utilizing a lot of threading/invoation, it would be helpful to be able trap the exception in the target method i.e. the faulty code, and since Microsofts BackgroundWorker (exceptions thrown in DoWork()) is able to do it, why can't I???

View 2 Replies

Use Moq's VerifySet In VB?

Jul 12, 2010

I have a function that updates a user in the asp.net membership provider.

[code]...

View 1 Replies

.net - When The Property Get And Set Method Has Been Called

Mar 26, 2010

i have the following property declaration

[Code]...

View 2 Replies

Why Do Property Setters Get Called More Often Than Expected

Oct 12, 2011

I have observed a behaviour in VB.net where property setters get called more often than seems necessary, in conjunction with calls to the sister setter method.

Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Console.WriteLine("Calling WorkReferenceTypeByReference")
WorkReferenceTypeByReference(ReferenceTypeData)
Console.WriteLine("Called WorkReferenceTypeByReference")
[Code] .....

Note the spurious call to the property setter following the method execution. I am supposing this behaviour is produced as a safety measure against inadvertently modifying the underlying property, despite this potentially being the intent. This behaviour in the case of ByRef vs ByVal usage is easily solved by choosing appropriate ByVal keyword, however hase recently noticed a more insidious behaviour, one that has caused a stack overflow of repeated calls, since the setter call would update a value that called the getter only.

Public Sub DoSomething()
Dim a As New CustomObject(anotherObject.AProperty(getterArgument))
End Sub
Public Class AnotherObject
Public Property AProperty as SomeType
[Code] .....

In the previous example, calling DoSomething() would fire the AProperty getter method, but then after that usage, would fire the setter method, which by program logic calls DoSomething() again. It is the automatic calling of the setter that puzzles me.

View 2 Replies

Textbox Control Which Has A Property Called 'StatusBerText'?

Feb 15, 2010

I've created my own textbox control which has a property called 'StatusBerText'. The idea is when the control has focus an event is raised and the text is shown in the status bar.

Below is my code which works, it starts with me.controls and looks for my textbox to add the handler. If it comes across a container it then starts again looping through all the controls in the container.

Private Sub NewCompany_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SetControls(Me.Controls)
End Sub
Private Sub SetControls(ByVal obj As Object)

[Code]...

As I said this all works, however, I would ideally like to put the 'SetControls' in a class so I just call it in each form rather than having to paste the entire code in all the time. To do this I will need to pass the address of the StatusBarChanged function through, is this possible?

View 4 Replies

Use Property Type In Expression?

Feb 16, 2010

I have a function which creates a different type of expression depending on the value of the variable passed in.[code]...

View 1 Replies

Custom Function For Datacolumn.expression Property

Jan 23, 2009

i read an article about datacolumn.expression property here [URL]. this is really great. but i was just wondering, for my case i want to use my custom function to use in the expression. basically, on my datatable i added an unbound column AGE. when i display records, i just want the age textbox to be populated with the computation of the person's age based on birthdate.

View 7 Replies

.net - Setter Not Visited When Using .Add?

Dec 19, 2011

I am trying to set a flag when a collection is modified - the logical place to do that seemed to be in the setter method. The problem is when I use this code

[Code]...

View 4 Replies

Created A Getter And Setter

Aug 12, 2010

I created a getter and Setter in Visual Basic. I have some questions though. Please look at the code below.

A.) At line 1 below, should "pieces" be declared as Private?

B.) In the IDE at lines 4 and 7 the IDE keeps changing those variables to uppercase so that the property name "Pieces" is the same as the variable name "pieces".Should I instead define the integer pieces with an underscore: _pieces ?That is the only way I can get around the IDE forcing the variable to become uppercase. [code]

View 4 Replies

Have A Column In The Datatable Called Amount And A Textbox Acting As The Filter Called Say Maxamount To Set It?

Feb 9, 2011

i was wondering if it possible to have a condition where lets say you have a column in the datatable called amount and a textbox acting as the filter called say maxamount to set it so the rowfilter when filtering the table will sum the number in the amount column until the number in maxamount is met, then stop and only return the rows where the total sum of the amount column is equal or less than the maxamount value, so i guess if the next row takes us over the maxamount it discards this row and returns the rows previous to it. is this possible using datagridview rowfilter or should i be loooking elsewhere to achieve this?

View 4 Replies

Combo - Sql Table Called Stock With Two Fields Called StockID And StockCode

Jun 5, 2011

I have an sql table called Stock with two fields called StockID and StockCode. I want the user to select the stockcode from a combo which in turn populates the stockid for that item into a lable on my form. I have already populated the stockcode into the combo but dont know how to compelte the rest.

Imports System.Data.SqlClient

Public Class cbo2
Private Sub cbo2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

[CODE]...

View 4 Replies

Form Called FrmPracDetails Which Is Built Up With A List View Called LvwColProc

Aug 11, 2009

I have a form called FrmPracDetails which is built up with a List view called LvwColProc. Therefore when you click a field on the LvwColProc it takes you to another form called FrmColProcessing, here you can make changes to certain fields which are also present on FrmPracDetails. What I want to do is when you make changes on FrmColProcesing and Click the Save Button (which calls the Save function)the changes appear instantly on FrmPracDetails. Please note, FrmColProcessing will always be open next to FrmPracDetails. I have tried to put this code in the Save function present in FrmCol Processing as shown below, but it doesnt Refresh FrmPracDetails form. [code]

View 1 Replies

Arithmatic Conversion In Getter/Setter

Aug 24, 2010

In my application I need to allow for someone to enter in a floating point value.However that value will be rounded up to an integer.The challenge here is that I am using a getter and setter.If I try and use mixed data types in the getter setter,[code..]

View 1 Replies

Properties - Call Setter From Within Getter?

Jul 29, 2011

I have a class like this:

Public Class MyClass
Private _intList As New List(Of Integer)
Private _avg As Decimal

[code]....

The Getter is calculating average and calls Setter to save the value. For some reason I cannot understand, the average is always 0. For example:

Dim c As New Class2()
c.Add(1)
c.Add(2)
c.Add(3)
Console.WriteLine(c.Avg.ToString()) ' This will print 0

What is the cause of this?

View 4 Replies

Displays One Of The Two Delegates Per Invocation?

Mar 27, 2011

I've been tinkering with Delegates, and now Multicast delegates. Every time I invoke two delegates It only displays one of the two delegates per invocation.

[Code]...

View 6 Replies

Exception Has Been Thrown By Target Of An Invocation.

Jan 15, 2012

I'm working on an application that contains a "BackgroundWorker", the "BackgroundWorker" worked fine but after I started to change some stuff it gives me an error ("Exception has been thrown by the target of an invocation.")... I used a breakpoint to see where it happens, the exception gets thrown at the "End Sub" line of the BackgroundWorker.I then deleted all the code inside of it and ran it again.I still get the error.

View 12 Replies

Exception Has Been Thrown By Target Of Invocation

Feb 27, 2009

What is the meaning of this error message?
"Exception has been thrown by the target of an invocation"

Instead of words, here is my code's logic :
while loop
run BGworker01
run BGworker02
...
run BGworker09
application.doEvents
thread.sleep(10)
end while

All the bgWorkers do the same thing (sending some data, only to different locations). When I run this loop with only 1 Background-Worker, it's all fine, but when I add the other bgWorkers i get the mentioned error at the "application.doEvents" part of the loop. I think it also points to another place (highlighted in green) inside one of the bgworker's code :
Dim FileStreamToSend As FileStream = New FileStream(fileToSend, FileMode.Open)
I thought it might be a problem that all bgWorkers are trying to read from the same file together, but when I tried using different file for each bgWorker, the problem persisted.

View 4 Replies

Exception Has Been Thrown By The Target Of An Invocation

May 28, 2010

I want to use mozilla control in my application.. But when i use Webbrowsercontrol i just use

webbrowser.navigate("http://www.google.com")

but this commant is not working with mozilla control ant when we try to navigate to any web address it gives following exception.

Exception has been thrown by the target of an invocation.

View 1 Replies

Exception Has Been Thrown By The Target Of An Invocation?

Jan 21, 2011

I know this is a relatively common error but I am working in an application that allows custom reports to be written using vb.net or C# for scripting. Error handling is very poor and I am not knowledgable enough to add my own (if it is even possible).

My code simply retrieves a value that is stored in a textbox on the report formatted as LastName, FirstName and truncates all characters after the comma. This value LastName is placed in a new textbox on the report. Here is my code:

Sub Detail1_Format
Dim lastNameFirstName As String = ""
Dim lastName As String = ""

[Code]....

The error happens when I use lastNameCommaIndex to set the number of characters in my substring. If I replace it with a number the report is published properly.

View 1 Replies

VS 2005 Invocation Exception Using AutoResetEvent?

May 16, 2009

I am using a background worker to process some login information. However, the background worker has to stop and wait for 2 events to happen. Once these have finished the background worker can complete its job. They are callback that will call the Set() method of the AutoResetEvent.

So I am using AutoResetEvent to set when these 2 events have finished. However, I seemed to be getting this error message

"Exception has been thrown by the target of an invocation." and Inner exception

"Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index". The exception usually fires when the registration success leaves scope.

The code for the background worker.

' Waiting for 'Account in use' and 'Register success or failure'
Private loginWaitEvents() As AutoResetEvent = { New AutoResetEvent(False), New AutoResetEvent(False) }

[Code].....

View 2 Replies

.net - SSRS Report Called From ReportViewer Control Displays No Data In The Report When Called With A Parameter

Apr 11, 2012

Can you look at my coding and let me know what I'm missing or doing wrong?I have a SSRS report that is called from a ReportViewer control and the ProcessingMode for this control is Remote. The report also has 1 parameter in it's DataSet.In the code I placed a MsgBox to make sure the code is finding the parameter and returning the parameter name. I am trying to stick the value of 10 into the parameter for playerID 10. Data for this player does exist.

I believe I need to add some more code to make this work but I'm not sure what else to add.

When the code executes the report is displayed but no data is shown in the report.

[Code]...

View 1 Replies

Office Automation :: Called "Freemind" That Is Called A 'mind Mapping' Program?

May 13, 2010

I recently found an awesome tool called "Freemind" that is called a 'mind mapping' program. It's similar to MS Visio but way cooler and more automated.I reeeallly would like to integrate this into a VB.net Form, but how?

Has anyone seen or heard of mind mapping inside VB.net before? Are there programs out there already that work with VB.net or anyone have an example they have seen / built that works?

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved