C# - WCF Serialization And Interfaces - Error: List(of Object) Cannot Be Converted To List(of IMyInterface)

Oct 16, 2009

Does link text mean I have to return a concrete implementation? Even though I am using svcutil with the /r that includes my entites(where IMyInterface is defined). I get no errors but it changes all List(of IMyInterface) to list(of Object) and I cannot deserialize it on the client

Error: list(of object) cannot be converted to list(of IMyInterface).

View 1 Replies


ADVERTISEMENT

.net - Returning A List Using Entity Framework, 'System.Collections.Generic.List Cannot Be Converted To '1-dimensional Array

May 3, 2012

i have issue returning a list in a web method. here is the code

<WebMethod()> _
Public Function getTags(para_parents As String) As List(Of getTypeDetailsByParentName_Result)()
Dim context As New PPEntities

[code]....

the error is

Value of type 'System.Collections.Generic.List(Of SaftyonRoad.getTypeDetailsByParentName_Result)' cannot be converted to '1-dimensional array of System.Collections.Generic.List(Of SaftyonRoad.getTypeDetailsByParentName_Result)'

View 1 Replies

List Of T Find Date Or Other Property In A Object In The List - Then Return Found Object?

Sep 3, 2009

After reading all the examples for list of T exists and Find and find first, none show how to handle multi-property objects. Below is bare bones example maybe someone could flesh out to show how this should be done.

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim DatePriceList As New List(Of DateAndPrice)
DatePriceList.Add(New DateAndPrice(Date.Parse("1/1/2000"), 10.12))
DatePriceList.Add(New DateAndPrice(Date.Parse("1/2/2000"), 11.12))

[Code]...

View 3 Replies

Display A List (Of Object) Which Has Single Objects And Child List (Of Object)?

Sep 6, 2011

Limited to using v2.0 of .Net framework (we use VB.net) due to environmental constraints on our servers.I've got an ASP.net webpage which pulls data from a webservice that performs checks on user accounts in active directory. Operators can check multiple accounts at one time using the web interface. The webservice returns a list(of AccountCheck) objects which themselves contain single properties like username, email address, and List(of AccountError) objects which contain multiple properties.[code]What I want to do is using some kind of repeater, create multiple panels or divs which contain labels showing the username, email etc, and a gridview which has the accounterror list bound to it to show all the errors. The users could be checking 2, 5, 7 accounts at once, and is dynamic.

View 2 Replies

Cast A List Of Object To List Of Interface That Object Implements?

May 19, 2009

I am working in VB.net and have a Class, Foo, that implements an interface, IBar.I have a List of Foo's, but I need to pass a list of IBar's into a function, but I keep getting casting errors, even when I use DirectCast.My code is [code]MainWorks works, but it would be really annoying and inefficient to have to do that everywhere I want to call this function.

View 4 Replies

Creating Array/list From Loaded Interfaces?

Aug 24, 2010

I'm having trouble creating a global array that i can use in other functions.

I have this code right under "Public Class myClass":

Dim LoadedPlugins As Array

Then in a function I have this:

Dim PluginList As String() = Directory.GetFiles(appDir, "*.dll")
For Each Plugin As String In PluginList
Dim Asm As Assembly

[Code]....

Now obviously that doesn't work, how can I add the tmpPlugin to an array or list so I can use it in other functions?

The main thing I need to be able to do is loop through all the loaded plugins and execute the CustomFunction in a separate function than the one that loads the plugins listed above.

View 1 Replies

Create List Of Child Objects From List Of Parent Object?

Jun 2, 2011

I would like to create list of child objects from list of parent object. Like If i have list of bookingroom which has one member room then i would like to create list of room from it.

eg. code:

Dim BookingRoomList As List(Of BookingRoom) = New List(Of BookingRoom)
Dim RoomList As List(Of Room) = New List(Of Room)
BookingRoomList = BookingRooms.FillGrid()

[Code]....

Is there any short cut method instead of iterating over for earch?

View 1 Replies

.net - Searching A List Of Objects In An Object List Using Linq?

Dec 22, 2010

I have 2 classes

Public Class Shipper
Public Property ShipperID As Long
Public Property CreateDate As DateTime

[Code].....

View 1 Replies

NullReferenceException Error Adding Object To A List

Jun 20, 2012

I'm trying to add objects from a class I created using data from an excel worksheet to a list using a for loop [code]When I run it I receive "System.NullReferenceException was unhandled by user code Message=Object reference not set to an instance of an object."

View 4 Replies

Asp.net Mvc - Creating A List (of String) Giving Error" Object Reference Not Set To An Instance Of An Object"

Nov 1, 2011

MVC 3 razor VB.NET project. I have resorted to manual building a list for a drop down box so I can insure certain values are available in the select list and also to control what the first item is in the list. The below is my code snippet for the part that is giving me problems..

[Code]...

View 2 Replies

VS 2010 "Object Reference" Error When Adding Object To List (Of T) Property

Apr 25, 2011

I have a class that has a property that I declare like this:

VB.NET
Private _DirectoryList As List(Of FileDirectoryInfo) ''' <summary> ''' Array of directories. ''' </summary> ''' <value>Object</value> ''' <returns>Directory array list</returns> ''' <remarks>N/A</remarks> Public Property Directory As List(Of FileDirectoryInfo) Get Return _DirectoryList End Get Set(ByVal value As List(Of FileDirectoryInfo)) _DirectoryList = value End Set End Property

[Code]...

View 2 Replies

How To Quickly Transform A List(Of Object) Into A List(Of "Object.field")

May 29, 2012

Suppose I have a list of Cat.

Public Class Cat
Public Property id As Guid
Public Property name As String
Public Property race As catRace
End Class

How can I quickly transform this List(Of Cat) into a List(Of Guid) using the id property?

I could do :

Dim newList As List(Of Guid)
For each item in catList
newList.Add(item.id)
Next

But I think there must be a way to do this faster (1 LOC). I just can't find how.

View 3 Replies

VS 2010 List(of Class) - System.NullReferenceException Error When Add The Info To The List

Jan 27, 2011

I'm getting System.NullReferenceException error when I try to add the employee info to the Employees list.

[Code]...

View 4 Replies

Deleting A File Using A Checked List Box - Error: Unable To Cast Object Of Type

Jun 21, 2010

I am trying to delete a file(s) from a checked list box, when i click a button.

This is the code i have:

Dim item As IO.FileInfo
For Each item In CheckedListBox1.CheckedItems
Try
item.Delete()
Catch : End Try
Next item

But i get the error: Unable to cast object of type 'System.String' to type 'System.IO.FileInfo'.

View 6 Replies

Populate A List(Of Object) In A Class Method, Where The List Was Passed To The Method As A Parameter

Aug 13, 2011

I'm trying to code a class of RandomNumber. One of the class methods needs to populate a "List (Of RandomNumber)" ... which was passed as a parameter to the method ... with 10 random numbers between 1 and 50. DEAD SIMPLE :)

View 6 Replies

Copy List Object To Another List Object

Jun 15, 2012

I am having a problem when setting VB.NET list object to another.I create an instance on ReadLocations and than create an object of ReadLocation where then I loop through ReadLocations and set ReadLocation1 equal to rl. What happens is that if I then go and change ReadLocation1 to something else (assdfhsd) it will also change the ReadLocations index. I am really confused why it would be doing that unless it is "=" sign means referencing instead of actually setting the value. Please help as I am a C# developer but the program I am modifying is in VB.NET.[code]

View 1 Replies

Error System.object Cant Be Converted To Sytem.String

Aug 8, 2010

i have problem LINQ query.In above,i got error system.object cant be converted to Sytem.String. What can be the problem? if i use string() instead of ArrayList, it doesn't raise error. But in String(), i should add items manually [code]

View 3 Replies

Generic TypeOf Operator - See If List Is A List(Of T) Variable - Error: "Type Expected"?

Jan 5, 2011

Dim x = GetType(List(Of )) 'valid statement
Dim list As New List(Of String)

Now I want to see if list is a List(Of T) variable: Dim isList = TypeOf list Is List(Of ) On the last line I get a compile error: "Type Expected". Is there any cheap-performance TypeOf operator alternative for generics?

View 2 Replies

Error - Red "List" Says Too Few Type Arguments To System.Collections.Generic.List(Of T)'

Mar 12, 2009

I have converted c# .cs to vb:= I have 6 errors on:

Red "List" says Too few type arguments to system.Collections.Generic.List(Of T)'
Orange "Calendar" says Value of type 'System.Windows.Forms.Control.ControlCollection' cannot be converted to 'Form1.Kobush.Windows.Forms.Appointment'.

[code]....

View 6 Replies

.net - ByRef Underlined With "Expression Expected" Error When Trying To Pass In A Object Of Type List(Of ClsFooDetail)?

Mar 3, 2010

I work with C# 99% of the time. However, I'm having to update some legacy VB.Net code and encountering an issue with VB.Net code syntax. The error that I get is "ByRef" is underlined and "Expected Expression" tag shows up when you hover over "ByRef". The "FooDetail.Load" function is written in C# and expects a List object passed as reference. Don't have any trouble using the same function in other C# classes. Can someone indicate what is wrong with below VB.Net code.

Dim FooDetail As New clsFooDetail()
FooDetail.FooID = FooID
Dim lstFooDetail As New List(Of clsFooDetail)
FooDetail.Load(ConnectionString, "Stored Procedure", ByRef lstFooDetail as System.Collection.List(Of(clsFooDetail))

View 1 Replies

Does An Object Retrieved From A List Get A Copy Of That Object Or A Reference To It

Feb 1, 2012

In VB.net, when I retrieve a value from a list do I get a copy of that value or a reference to it?

dim blah as someObject
dim listOfBlahs as list(of someObject)
listOfBlah.add(new someObject(1))

[Code]....

View 2 Replies

Why Is List.add() Adding Items To Object AND Source Object As Well

Jun 15, 2011

I need to be able to add elements to a copy of mylist.testlist without modifying the global mylist object. (Which seems to be happening via the below code.)When I am working on x, which should be a totally separate object, mylist is getting modified as well. How can I fix this? I have worked with lists extensively and never seen this behavior before. I have tested and reproduced the problem in .NET 3.5 and .NET 4.0 on Win 7 Pro 32bit.

Source Code:

Public Class Form1
Public mylist As New test
Sub Main()

[code]....

View 1 Replies

Determine If List(Of Object) Contains Control Object ?

Nov 8, 2010

How to know if a List(Of T) contains any control object without using a loop ?This doesn't work

Dim lstObject As New List(Of Object)
lstObject.Add("STRING")
lstObject.Add(2)

[code].....

View 9 Replies

Disposing Object Collected In List (Of Object)

Jul 29, 2010

I would like to ask what is the efficiency way the clean and dispose the object collected in the List (Of Object)?

Is that by calling the List.Clear() method will automatic clean all the object collected by it?

View 7 Replies

VS 2008 Remove Object In List(Of Object)?

Feb 11, 2011

I am able to populate an object and output everything. How do I remove say the name2 object?

la.Remove(Logins("name2")) doesn't seem to work.
Private Sub btnListArray_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnListArray.Click

[code]....

View 9 Replies

Can Get A Specific Object Out Of List

May 23, 2010

I have a number of custom objects of type X. X has a number of parameters and must be unique in the collection. (I created my own equals method based on the custom parameters to examine this) In each object of type x, I have a list of objects y.I want to add/remove/modify easily an object y. To write the add method, it would be something like add(objTypeX, objTypeY)I would check or the collections already has a objTypeX.If so: i would add the objTypeY to the already existing objTypeX else: i would create objTypeX and add objTypeY to this object. [code] Which collections should I use? I tried with hashset but i can get a specific object out of the list, without run down the list till I find that object.

View 1 Replies

Converting An Object To A List Of Something

Aug 3, 2010

I'm trying to convert an object, that is a list of something, to that list, but I'm having problems figuring out exactly how to do that. I have created the following code:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim a As New List(Of String)

[Code]....

View 4 Replies

List Of New Custom Object?

Sep 2, 2010

I created a simple (for now) custom object:

VB
Public Class Form1
Dim AllPartFiles As List(Of Part)

[code]....

As I search a folder for files, it returns FilePath as a string for each file in the folder, then assigns a new Part.FullFilePath to the current returned FilePath, then add the Part to AllPartFiles list. So I can retrieve each Part from AllPartFiles later. But everything I try doesnt work.I know below is wrong, but might show what Im trying to do:

VB
Dim Files() As String
Files = System.IO.Directory.GetFiles(RootFolder, "*.ipt")
Dim k As String

[code]....

Create a New Part, change its values, and then add it to AllPartFiles list for later, then repeat?

View 12 Replies

List Of Object Search

Jul 18, 2012

I have a question on searching a List(Of CLass). I am not sure how it is labeled List<OF T> or List(Of Class) However you label it here is the Class EXT.[code]As you can see from the SearchForExtension Sub I have 4 different ways to search for the extension. The index is used to select the searched for row in the DataGridView.

View 2 Replies

Using Contains With Object(s) Of Type List?

Feb 26, 2010

I'm trying to use the Contains method but it refuses to recognise a like for like object. Both lists can contain the same objects at the time the statement is called at run-time and the if statement still executes at each iteration of the for loop.

[Code]...

View 9 Replies







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