[2008] Serialize 2 Lists(of Classes) Into 1 File?

Feb 5, 2009

how can i serialize 2 lists(of classes) into 1 file?

View 5 Replies


ADVERTISEMENT

XML Serialize Friend Classes

Sep 23, 2009

I have a few classes (about 15 or so) in VB.net (2005) that I would like to be able to serialize to xml. Unfortunately they are labeled as friend classes and cannot be exposed outside of the assembly.The assembly is a dll that is a com interop plugin to a CAD system. I have set all of my classes as friends so that they are not exposed outside of the assembly for 3rd party use. I am wondering if I even need to do that. Setting the class to public would allow me to serialize things. However I don't want people linking to the assembly and using the classes.Should I even worry about other programs linking to my assembly? In fact I don't think there is a large chance of this happening. I just don't like the idea of having almost all of my classes with a public scope.Is there a way to make a friend class serializable?

View 2 Replies

Multiple Classes For Serialize Objects?

May 9, 2009

I have one class with <Serialize> attribute called Tree. And Tree class has an arraylist of TreeNode classes. Is it possible to use Soap to convert the Tree class and arraylist of TreeNode classes to one xml file or binary file? If it is possible, do i need to use <Serialize> attribute on TreeNode classes too? If not, what should i do then?

View 3 Replies

VS 2008 Serialize A Class That Implements An Event That Don't Want To Serialize?

Aug 17, 2010

If a class is serialized and has events fired from it that are handled on a form you get the error "Form1 cannot be serialized" in c# you can use (to work around this):

[Code]....

View 1 Replies

Download Xsd Specifications From A Web Service And Automatic Converting (serialize) These Schemes To Classes (visual Studio - .net)?

Aug 8, 2011

I want to download xsd specifications from a web service and automatic converting (serialize) these schemas to classes (visual studio - vb.net). If the organization that is responsible for the xsd schemas alter them in a way that only my class corresponding to the xsd have to be altered (not the rest of my code) I would like to automatic update my xsd corresponding class.

I use vs2010. What I want to do is: call a web service where I can send in an input parameter to the service which specifies the xsd I want to retrieve (the service is GetShemaDefenition and returns an object with the schema specification in a string property of the object). I den have to read the xsd string from the string property and convert this to a class representation of this xsd specification. Is it possible to do this automatically? I have done this manually by using xsd.exe. If the owner organization of the xsd has altered the xsd specification, I have to test if there is a new specification, and if there is I have to build a new class representation of this xsd? Is it possible to do what I want? And how would I know if it has been a big change in the xsd which also affect other parts of my code, not just the class representation of the xsd?

Update:I use one web service where one of the properties is a string. The string is an XML inside a CDATA block. The organization which provides the web service will not pares the xml inside the CDATA block but instead forward this to another organization that will use the xml data. The organization which uses the xml data specifies the xsd schem that I have to follow to generate my xml correct. This is the xsd schema I can get from another web service. I don't really understand what I can do with this xsd file from the web service. What can I do with it and why do I want to download it from the web service, when I can't use it automatically? Because I have to manually do the changes when the xsd changes I can easily download the xsd schema from the organization's home page and make the new class with xsd.exe.

View 1 Replies

Event Vs Recursion - Program That Has A Large Set Of Classes In It - Each Class Will Need To Add One Or More Strings To One Of Two Lists

Mar 14, 2010

I have a program that has a large set of classes in it. A certain incident (I won't call it an event, yet, as that has a specific meaning that will cause trouble later) needs to a relatively small subset of these classes a question. The subset of classes will need to respond to the question, but for it to be able to do so, the classes may first need to ask a similar question of the same subset, which may prompt yet a further question, though this recursion will never go more than three or four levels down. Since only a small subset of these classes will participate in the questions, while the majority will never participate, and since all of these classes are virtually identical, and I can know at design time whether any given class is part of the subset or not, an event is appropriate. The main class can raise an event, and those classes in the subset can handle the event, while those classes that are not in the subset won't handle the event. Furthermore, any of these classes can raise the event again with different parameters, as needed. Thus far, an event appears to be ideal.

The problem is this: As a result of the event, each class will need to add one or more strings to one of two lists. Event handlers can't return anything, so I can't be using the return values from functions to populate these lists.

Two options appear possible:

1) Include the two lists in the event arguments.

2) Have the two lists be accessible to all classes, and don't pass anything around.

The second part of the problem is that the event is effectively a question being asked of each class, and no action can be taken until each class has responded. If I simply raise an event and let each class respond, can I be certain that all classes that should respond have? An alternative solution would be to have each class expose a method, and call these methods for each class in turn. By doing this, I could get return values, but I would have to call the methods for ALL the classes, not just the subset that actually cares (the classes are all different types, but they all implement a common interface, and are added to a List (of ) that interface, so I can iterate through them all without much difficulty). So, the event seems more efficient, but adding a function to the common interface for the classes is the approach most certain of being a solution.

View 7 Replies

VS 2008 : Serialize The Downloadjob Into A XML File?

Jun 5, 2010

i made an assembly that contains a class DownloadJob / I load the assembly into another project (the download manager) and i am trying to serialize the downloadjob into a XML file as such:

Public Sub Save()
Dim objStreamWriter As New IO.StreamWriter("C:Product.xml")
Dim x As New System.Xml.Serialization.XmlSerializer(Me.GetType)
x.Serialize(objStreamWriter, Me)
objStreamWriter.Close()
End Sub

I put the save function in the assembly in the class downloadjob itself so ME refers to the DownloadJob class object that i want to serialize I get this huge exception:

The assembly with display name 'Download Client.XmlSerializers' failed to load in the 'LoadFrom' binding context of the AppDomain with ID 1. The cause of the failure was: System.IO.FileNotFoundException: Could not load file or assembly 'Download Client.XmlSerializers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

[code]....

however when i turn off exceptions serioalization works and i dont have a problem.

View 2 Replies

Serialize Datatable To A Binary File Then Add New Rows To File

Apr 29, 2012

I need to save a datatable to a binary file , in binary format , in order to make the process fast because the datatable may contain up ten millions rows. So , XML is not favorable because it makes the file large sized , and the process will be slow.

I managed to save the datatable to a binary file , and it works fine , but the problem when I try to add new rows to the existing binary file (using a datatable with the same schema , but different rows data) , it copies the schema of the datatable to the binary file, making it very large.

[Code]...

View 1 Replies

Serialize A Class With A Dictionary To A XML File?

Jul 20, 2011

I want to Serialize and Deserialize a configuration class containing a Dictionary to a XML file.Here is an exemple of what the class look like.

Imports
Public
Class

[code]....

When I try to serialize it with a XmlSerializer I get an exception saying to me that it is impossible to serialise Configuration.Parametres because it implements IDictionary.

DateTime
)
Configuration
System.Collections.Generic

View 2 Replies

Serialize The Data And Save It To Xml File?

Feb 26, 2011

I have a list with class user and I am able to serialize the data and save it to an xml file. However I just cannot figure out how I

can deserialize that .xml file and save the data into a new list.

The following is my code:

Dim Users As New List(Of User)
Dim objStreamWriter As New StreamWriter(filelocation)
For Each btn As Button In myNodeBtns

[Code]....

I want to read the data back from the file and save it into the mynodebtns list where I orginally took it from.

View 15 Replies

VS 2008 Serialize Arraylist To Xml

May 12, 2011

I know how to seralize my arraylist to xml using vb.net?

View 2 Replies

VS 2008 Trying To Serialize A Class?

Apr 25, 2009

I'm trying to serialize this class:

<System.Serializable()> Public Class Person
Private _FirstName As String
Public Property FirstName() As String

[code]....

View 2 Replies

Sorting 2 Lists Based On Only One Of The Lists?

Apr 1, 2011

I have two lists. One list is a list of names, the other list is a list of how many times each name is found in the first list noted in the database

so...
Nick
John
Jim
Jack

is the firs tlist

10
13
13
2

is the second list. Nick had 10, john 13 and so on.I want to sort the second list from large to small, but have the index for the first list still linked to the correct amount of calls.i do it this way so I can

for x = 0 to num_of_names
string = lst_name(x) & "-" & lst_count(x)
next x

View 3 Replies

VS 2008 - Serialize Array Of Structure To XML

Jun 3, 2010

I desperately seek for a code sample to serialize an array of structure elements to a XML. To serialize a simple object of a structure I used:
Private Sub saveEntries()
Dim FS As New FileStream(path, FileMode.Create)
Dim XS As New XmlSerializer(GetType(personEntry))
XS.Serialize(FS, entries(0)) 'serialize first entry of an array - success
FS.Close()
End Sub

Structure looks like this:
<Serializable()> Public Structure personEntry
Dim name As String
Dim d, m, y As Integer
End Structure
Private path As String = "data_file.xml"
Public entries(2) As personEntry
But how to apply this to an array?

View 5 Replies

VS 2008 Serialize A Property Of An Object As Another?

Aug 4, 2010

Basically I have created an object that has a graphicspath as one of its properties... and i want to serialize it...

I was basically wondering if i could somehow automate the serializing of the GraphicsPath to another object (for the purposes of serializing since the graphicspath cannot be natively serialized)

eg serialize it to a list of the following class:

vb
<Serializable()> _
Public Class sPath
Public PathPoints() As PointF

[Code].....

View 1 Replies

Throw In Asp.net - Run The DerivedPage - My Log File Lists The Error As Line 7

Apr 14, 2011

Below, why doesn't Throw maintain my originating line number? If I run the DerivedPage, my log file lists the error as line 7. Shouldn't it say line 4? It would make sense if I had Throw ex, but I don't. Isn't Throw by itself just supposed to rethrow and bubble up the error? If I remove the Try...Catch block entirely in DerivedPage, then my log file correctly lists 3 as the error line, but I am not able to log any info in case of an error. What can I do to maintain my DerivedPage, and still have my log keep the correct line number?

Public Class DerivedPage Inherits BasePage
Page_Load(o,e)
Try

[CODE]...

Base page:

Public Class BasePage
Protected Overrides Sub OnError(e)
MyBase.OnError(e)

[CODE]...

Log.Error does output the InnerException if it exists. It does in this case. However, the stack trace for the InnerException doesn't contain a line number, just the Exception details.

View 3 Replies

VS 2008 Richtextbox Ordered Lists ?

Sep 15, 2010

I have searched the Internet and this forum for any help on making specialized lists in a Richtextbox instead of the default bulleted list (i.e: Numbered, Upper Roman, Lower Roman, etc.). I know that the default Richtextbox only supports Bulleted lists. I have tried to find a custom Richtextbox control that does it and nothing.I found this code snippet on another site, but after messing with it for a while I just put this on the back-burner while I worked on other things.

View 2 Replies

VB 2008 - Lists And Null Value Exception Error

May 10, 2009

I have one list that pushes to another list. Think of a shopping cart situation. If you double-click on the white area after the list of items in the first window, I get a null exception error when I push the info to the second window. How can I avoid that error??

Existing Code is below...
Private Sub lstBooksAudio_doubleclick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstBooksAudio.DoubleClick
If lstBooksAudio.SelectedItem = "" Then
MsgBox("Please Click on an item.")
[Code] .....

View 11 Replies

VS 2008 Creating Events For Lists Of Buttons?

May 21, 2010

i have created a list of buttons using the following

Dim Butt(20) As Button
Dim i As Integer = 0
While (i <= 20)
Butt(i) = New Button
Me.Controls.Add(Butt(i))
i = i + 1
End While

this means that buttons are created in the code and not on the form to begin with, so I don't know how to create an event for the click of a button in a list. Is it possible to do it with a parameter for i so that there is only 1event for all buttons in the list, and i is the button index array clicked?

View 1 Replies

A Disk File Listner Lists All Files On All Disks On Local Computer?

Jul 27, 2010

I'm working on a program that lists all of the files on all of the drives on my computerI'd comments. To use the program Start a new Windows Forms application and replace the code on Form1 with the code listed here.

Imports System.IO
Imports System.ComponentModel
Imports System.Globalization

[code].....

View 19 Replies

VS 2008 - Are Arrays Considered A Type Of Collection Like Lists

Mar 2, 2010

Ever since I started using VB.Net I have been using the Generic List collection List(Of <Type>). Arrays, I haven't used so much. I used them a lot more when I wrote C code years ago.

1.) Are arrays considered a type of collection like Lists, Dictionary, Queue etc are? Or are they in their own category.

2.) Can I iterate over an array with a For Each loop like I can with other collections or do I stick with the normal For loop for arrays?

3.) There are certain methods that return arrays. Can I set a list object to hold this return value instead of an array?

View 6 Replies

VS 2008 : Having The Values For Each City Selected Via Two Drop Down Lists?

Apr 15, 2009

I've written a program to work out the flight distance between a set of seven cities around the world using a 2D array but was wondering how I would if possible go about having the values for each city selected via two drop down lists (say start city and destination city).

Public Class frmDistance
Private Sub Flightdist_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim rowcolumn(7, 7) As Integer
Dim sr As IO.StreamReader = IO.File.OpenText("Distance1.Txt")

[code]....

View 1 Replies

Know If An Array Of Lists Contains Similar Items (similar Lists)?

May 20, 2010

I know how to check whether an item exists in a list using (MyList.Contains), But I do not know how to check the whole list. For example (use one button and one richtextbox):

[Code]...

View 14 Replies

VS 2008 - Multithreaded Crawler - Each Time A New Thread Accesses One Of The Lists The Content Is Changed

Mar 18, 2010

I have written a multithreaded crawler and the process is simply creating threads and having them access a list of urls to crawl. They then access the urls and parse the html content. All this seems to work fine. Now when I need to write to tables in a database is when I experience issues. I have 2 declared arraylists that will contain the content each thread parse. The first arraylist is simply the rss feed links and the other arraylist contains the different posts. I then use a for each loop to iterate one while sequentially incrementing the other and writing to the database. My problem is that each time a new thread accesses one of the lists the content is changed and this affects the iteration. I tried using nested loops but it did not work before and this works fine using a single thread.

Here is my

SyncLock dlock
For Each rsslink As String In finallinks
postlink = finalposts.Item(i)

[CODE]...

Finallinks and finalposts are the two arraylists. I did not include the rest of the code which shows the threads working but this is the essential part where my error occurs which is basically here postlink = finalposts.Item(i) i = i + 1

ERROR: index was out of range. Must be non-negative and less than the size of the collection. Parameter name:index

I tried copying it to a new list but dosent work.

View 9 Replies

VS 2008 Bound - Source Data Of Drop Down Lists Be Separate Queries / Datatables?

Jun 2, 2009

I've got a couple of drop down lists for languages. I bind them to a language list that comes from a query. Then the fields are also bound to the row in the DB they relate to. I have several panels with the language drop down - each "tied" to a different table in my DB. When I call up different records on the same panel the drop downs immediately "set to the position" of that rows language in the list. But when I call up another panel - tied to another database table - I see that language in the drop down.

[Code]...

View 9 Replies

Use LINQ To Filter Collection Of Nested Classes To Yield Dictionary Of Unique Properties Of Those Classes?

Jan 23, 2012

I have two classes, one nested in the other. [code]Neither "Name" or "ID" are unique between operations and records.I wish to construct a dictionary using LINQ = Dictionary(Of String, Of List(Of Integer), whereby the keys are uniqe examples of Names in my collection and the values are the collective set of distinct IDs that are associated with those names.

View 2 Replies

VS 2010 Structure Classes So That The User Interfaces Though A Single Class While The Supporting Classes Are Hidden From Their View?

Jun 13, 2012

How can I structure my classes so that the user interfaces though a single class while the supporting classes are hidden from their view? I think its best understood in an example:

Public Class MyInterface
Public Economic as EconomicClass
Public Sub New()
MyBase.New()

[code].....

So you might ask why am I even separating them? It's strictly for others who will be working with this interface. I need to funnel them though a logical structure:

interface.Economic.MyMethod
interface.Currency.MyMethod
etc

This way everything is already handled for them in the background and they only need to run the method they need. I don't know if I can have it both ways in VB.NET.

View 23 Replies

VS 2010 Calling Subs And Functions Within Classes That Are Within Classes?

Oct 24, 2009

Here is some example code of what I mean:

vb
Public Class Form1
Private Sub Button1_Click(ByVal sender as Object, e as systemEventArgs) Handles Button1.Click

[Code]....

View 5 Replies

Derived Classes Cannot Raise Base Classes

Jul 10, 2009

I m trying to raise Click event of Textbox explictly but I m getting "Derived classes cannot raise base classes" error.[code]....

View 1 Replies

Combining Classes And Modules Into One File?

Feb 5, 2011

Is it ok to use some classes and modules inside a single VB file ?

At present, I used to create them in separate files by choosing Project menu --> Add Class/Module

I was thinking about combing them into one file. Is there any merit or demerit on this approach ?

View 6 Replies







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