Convert A System.Object To A System.Collections.Arraylist?
Oct 13, 2010
I am using Visual Studio 2005 and am writing a SSIS package. In the package I have a VB.Script that looks at a directory on a server and creates a list of the files. I then have a store Proc that looks at a table and gets a list of files that matches the files in the first array. The result is a fullresultset. The next step I need to create a 3rd array that only contains the rows from the first that are not in the second. However, I am getting the following error. Error: The script threw an exception: Unable to cast object of type 'System.Object' to type 'System.Collections.ArrayList'.
What's really the point in using the former?It's hard to use linq if I used the former. I have to convert that to an array first which is difficult because there is no (asarray) function.I think I would change all of my code that's using System.
Collections.Specialized.StringCollection to System.Collections.Generic.List(Of String)
I am getting following error whenever I want to use IIf function inside entity framework query.
LINQ to Entities does not recognize the method 'System.Object IIf(Boolean, System.Object, System.Object)' method, and this method cannot be translated into a store expression.
I recently discovered that the standard System.Boolean value is actually 32 bits - this seems pretty "far out there" since it's only ever going to be 1 or 0 - I found this information in somebody's blog which contained 3rd-party documentation on the System.Collections.BitArray. According to this blog, the individual Boolean is 32 bits while the individual index entry in a BitArray is actually just 1 bit - official documentation here at
MSDN indicates that in reality, the BitArray is just an array of Boolean Values (which would be the same size as any other boolean) that provides methods and functions useful in deconstructing System.Byte values into the BitArray and reconstructing the BitArray back into a System.Byte (same with System.Byte()).
I'd rather not go through a lot of code to restructure Boolean Arrays into BitArrays unless there's going to be some genuine memory-use improvement (which I'd expect to see if I converted large Boolean arrays - at 32 bits per index - into large BitArrays at 1 bit per index). I'm also interested to know if the Boolean is actually a 32 bit monstrosity.
How can I convert an object of type System.Data.Linq.DataQuery to System.Linq.IQueryable?I'm working with Visual Basic/Silverlight, and the source code of my query is as follows:
Public Function Get_Cli_Pag() As IQueryable(Of V_Cliente_Pagare) Dim Qry = From P In Me.Context.Pagares Join C In Me.Context.Codigos On C.Codigo
I have a series of API calls that are returning J# data types. I have been able to convert most of the data types (Integer, Boolean, Double, Float, etc) just fine.What I need to do now is convert a java.Util.Collection to a VB .NET collection (ArrayList)
Here is my attempt:
Public Function MakeDotNETCollection(ByVal javaCol As java.util.Collection) As Collection Dim dotNetCol As Collection
[code]....
I keep getting a runtime error "Unable to cast object of type 'AbstractListlistIterator' to type 'System.Collections.IEnumerator.
I have created a Dictionary class (MyDictionary for the example). I am currently trying to pass MyDictionary into a function, filter it into a new instance of MyDictionary and pass this new instance into another method. When I am attempting to create the second instance from the filtered first instance of MyDictionary via Lambda Expressions and the ToDictionary Method, I am getting the following error:
Unable to cast object of type 'System.Collections.Generic.Dictionary`2[System.Int32,System.String]' to type 'MyDictionary'. I have simplified the example and recreated it in LINQPad and am getting the same error.
I have a text-boxes that use both the validating event as well as the lostfocus event.I have pinpointed the exception in the post title to the validating events.[code]Maybe I am unaware that CancelEventArgs are not suppose to be used in the validating event? [code]
I´m gettin the error Calling the fuction GetListItems but is kind weird because it works in Visual Studio 2008 Express but no in Visual Basic 2010 Express:
Dim ndQuery As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "") Dim ndViewFields As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "") Dim ndQueryOptions As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element,
I've got a webservice serialization issue that is causing quite a headache and am hoping to get a little assistance before I end up pulling my hair out or something equally drastic.
I am having trouble developing an asp.net page. I can create custom collections and use them in win apps, but when i reference the system.collections namespace, the page response hangs up. No exception info is passed back or anything. The page just freezes. Is this a common problem. I am wondering if its due to the assembly not being present (but am unsure why an exception wouldn't indicate this.).
ok this code will save data withc is URL from textbox and load it to listbox , but i want it save first name of uRl like google then in other textbox put URl and save so when its load data its shows only name like Google not [URL] in listbox sometimes the link is too long and it will be not good interface in form1 and then when u click Google in listbox it open its URl [URL]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click My.Settings.FavList.Add(url_text.Text)
I have a lists of different custom classes and each must be sorted severals times before the algorithm is complete. For each sort I wrote a comparer. Sofar so good. Everything works. But: By now I have abou a dozen different comparers in more than one class and it is still getting more. I wonder if there is a way to limit the number by writing a new general function that can be used to sort all lists without the need for a specific comparer.Below is what I've got so far. But it does not work.
"System.Collections.Generic.List(Of ClassA)" can not be converted into "System.Collections.Generic.List(Of Object)."
If i wish to put items into a System.Collections.Generic.Dictionary, I can either Add or set the Item.I know if you do Add it helps you check if the key already exists and if not it throws an exception.Now I'm curious, so if I'm adding a ton of items, should I prefer setting Item instead of Add since Add does unnecessary checks that may actually slow things down?
I have a fairly lengthly block of code that I'm trying to convert from VB6 to VB.NET. The ArcObjects GIS code basically looks at a table and groups a bunch of GIS layers together and adds them to the ArcMap table of contents. I'm having trouble with this line when testing it in Visual Studio 2010: [Code]
I am getting the following erro message: "Unable to cast object of type 'System.String' to type 'System.Predicate`1[System.String]'." on the line of code: If Not StrgFrag.Exists(wrd) Then I was expecting a True/False response and assumed it would work given that wrd is a String variables and StrgFrag in a List(of String). Do I need to reference the wrd variable differently? Dim StrgFrag As New List(Of String)
How can I have it so that you can add items to a System.Collections.Specialized.String Collection but only if it is not there already? I have already found the code, but deleted it and cannot remember it. It is something like[code]....