Serialize A Class Containing A Public Event?
May 14, 2012how can i serialize a class containing a public event + withevents child classes each containing a public event?
View 3 Replieshow can i serialize a class containing a public event + withevents child classes each containing a public event?
View 3 RepliesIf 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]....
Can i add an event to a Public NotInheritable Class?, in particular i would need to have an event that would listen to property change.System.Web.ClientServices.ConnectivityStatus has a property IsOffline, i would need to know when this property has changed?
Any other way to achieve this?VB.NET to C#[URL]..
I would like to know how to call the "Public Class Test" that I created in my app which creates a directory and subdirectories. Now, how and where do I call or reference that "Public Class Test"?
I am using VS2008 (vb)
I'm using VB NET 2005 I have genereted a public class with one event so declare
Public Event Interupt()
I insert this code where I want to generate the events
RaiseEvent Interupt()
To use this class in other class use this code
Public IClass As New Cl
Public WithEvents Data As Cl
The code for the su of event is this:
Public Sub RsEvent () Handles Data.Interupt
Why doesn't came generatethe RsEvent?I verify in debug with break point that the code raise event is executed
I can access a module from code behind but not from the aspx page in inline VB code <% ... %>.
View 2 RepliesImports System
Imports System.Threading
Imports System.ComponentModel[code]....
how to declare "smsport" on class smscomms as public so that it can be access in class form1 or button1_click event.
I need to look at the properties of an object and I cannot instantiate this object in the proper state on my dev machine. I need my client to run some code on her machine, serialize the object in question to disk and then I can analyze the file.[code]...
View 2 Replieswhat is the fastest way to serialize and compress a class?
what are the consideration to be made when a long list of objects(classes) have to be serialized and compressed one after the other?
I have an XML file:
<?xml version="1.0" encoding="UTF-8"?>
<MyProducts>
<Product Name="P1" />
[code].....
I'm trying to serialize this class:
<System.Serializable()> Public Class Person
Private _FirstName As String
Public Property FirstName() As String
[code]....
CustomLineCap does not have the SerializableAttribute applied to it. I want to add a property of this type to an object graph that is currently being serialized/deserialized with a BinaryFormatter. I tried switching to XML serialization but it has a bunch of extra requirements and I don't want to fool with that esp. since it's not my code; it's some open source I downloaded. If there's a way to get BinaryFormatter to ignore the property, that might work. I'd rather subclass it; I just don't know if that will work either.
View 1 RepliesI am trying to figure out a class/struture to handle the following JSON format:
{
"ReturnData": [
{
"id": "msg2DoesNotExistName",
[Code]......
I may or may not have Data for ReturnData and SetValue (one or both at a minimum). I am trying to let the serializer handle most of the formatting without having to check for empty sections and single-item arrays.
I am trying to serialize a class that contains a generic list, and I am finding it all works with the exception of the generic list property. That is to say the other properties are serialized fine and no error is produced.
I have in the past serialized an arraylist - but I thought it was possible to do a generic list in the same way.
Am I missing something or is it not possible to serialize/deserialize a generic list - I have read mixed comments on this..
The relevant parts of the class that gets serialized is defined as..
<XmlInclude(GetType(cConfigUser)), _
Serializable(), XmlRoot(ElementName:="Config")> _
Public Class cConfig
[Code].....
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
I have a issue in a serialization process. I'm trying to Serialize a part of a bigger class.
I've a Class named MyBigClass with contain many property and method, and some of them may not be Serializable.
And I'm trying to Serialize one property of the MyBigClass class, witch is a SortedList named SubClassXList defined as SortedList(Int32, ClassX)
My problem is when it is time to serialize the SortedList (SubClassXList) a error tell me that a Class (say Class B) could not be Serialized because it is not marked as "Serializable", but the Class B in question have nothing to do with the SubClassXList in question.
The only thing I could see, is that the Serialization method try to also Serialize the Main Class (MyBigClass).
Here is the method that I use to Clone a Object ClassX do have the attribute "Serializable()"
Public Function CloneObject(ByVal pObjectToSerialize As Object) As Object
' Create a memory stream and a formatter.
Dim ms As New IO.MemoryStream()
[Code].....
what is the error in the bleow: 'Public Event OnFilterAdded()' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event. Note: the error line is italic underline
Imports System
Imports System.Collections
Imports System.Configuration
[Code].....
I need to be able to serialize a class into a string, and I know of 2 patterns:
1) (normal) Serialization pattern
2) Proxy Serialization pattern
I've read [URL] (the only website in google that talks about the proxy-serialization pattern) and still cant find the advantage or benefit of using this pattern. Could someone explain what exactly is the proxy serialization pattern, or rather exactly what problem does the proxy-serialization pattern solves that the normal-serialization pattern doesn't solve?
I'm trying to serialize the main class in my VB solution. I've added the Serializable attribute at the top of my class like so:
[code]...
I'm guessing this is because you can't serialize the form that is attached to the class or something, but I really don't know what I'm doing. Can I serialize all of the objects contained in my Form1 class somehow, without getting this error? I don't want to store any data about the form controls, I just need to save all the objects that I've defined at the top of the Form1 class.
I want to created a nested class that can only be visible to and instantiated from the parent class.But I also want to be able to use an instance of the nested class through a public variable of the parent class.I tried making the nested class private, or making the nested class' constructor private, but it won't compile.Is it possible to do this in .NET?
[Code]...
I have a VB.NET singleton class which implements Serializable:
Imports System.IO
Imports System.Runtime.Serialization
<Serializable()> Public Class CoordinateHistory[code].....
My problem is that I can't actually call .Serialize() on the instance of this class, like all of the examples online show. What am I doing wrong?
Question: I must get the content of all sessions in a HttpModule, under .NET 1.1. (don't ask my why certain people still use it) I can write the module, I can get the sessions. But... sessions are stored as
[Code]...
How best to manage multiple dat files for serializable objects of the same class. If one of my data files goes past a particular size, I want to create a new file. I then loop through both files when I do processing. Is there any easier way to do this and what's the best size to do this at in terms of performance?
View 1 RepliesI can't make difference between public class and private class and friend and protected friend class.
View 1 Replieshow to declare an internal class within a public class using vb.net?
View 2 RepliesI'm posting this there is a relationship with my previous post [URL]
I have two projects, namely:
1. Project1 (Windows Application)
2. Project2 (Class Library)
in Project2 there are several classes:
* frmLogin.vb
* frmCustomer.vb
* clsGlobals.vb
in my case, I want to frmLogin.vb and frmCustomer.vb not called in Project1 and I can only call is clsGlobals.vb
I need to convert the following code, so that it exists as a created class "Payroll" that utilizes "Get" and "Set" elements. Unfortunately, I'm completely lost.
Public Class frmPayroll
Private Sub frmPayroll_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
[code].....
Is it possible to raise event in one class and handle the event in another class? If so, how?
View 6 RepliesI never used Public Event, but now I have this line:
Code:
This SHOULD be a "trigger" when something in the event log happens.
Now I have 2 questions:
How do I work with public event? In other words, if I write something like this:
Code:
Is it right?
Last question:
Is there any other way to check event log? I found this: [url]
But is a service, I'm writing an application.
I'm getting an error in .net when trying to declare a Public class on my code behind page.
Partial Class _Default Inherits System.Web.UI.Page
Public someVariable as integer
Public someClass as className
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load [...]
The error I'm getting is BC30508: 'someClass' cannot expose type 'className' in namespace '<Default>' through class '_Default'.The goal here is accessing the class properties in script blocks on the aspx page like this <%=someClass.classProperty%>
I'm not sure if I'm trying the right methods (I've tried several ways of declaring the public class) or if it can even be done..