|
All,
I am having a bit of a headache with serialization of a custom class when using remoting. I am sure the problem is when remoting serializes a List<> of any type.
I was following the article by Marcel Heeremans - http://www.codeproject.com/KB/IP/TwoWayRemoting.aspx[^]
I managed to convert the program into a VB.NET service that communicates with a client exe. However, I wanted to create a custom type to enable messaging to a client.
I created my custom class that would be passed to a client via callback. This class is MessagePrompt (see below). I have changed my list type to String for this post as this fails as well as having any list type.
When the object is passed from server to client via callback, it fails. No exceptions are raised. However, from the tracing, I can see the object get successfully serialized at runtime. However, the client does not receive the object in the callback.
If I comment the following line, the the client does receive the object in the callback:
info.AddValue("Actions", _actions, GetType(List(Of String)))
If I manually serialize and deserialize the object then with XmlSerializer and StringWriter/StringReader, then it would appear to work fine in the client application.
Are there any issues as to why this would fail?
My assemblies are not strongly names as this causes the client callback to not work from the off. Therefore nothing is installed in the GAC.
Am I missing something?
Any pointers as to what I need to look at?
I can change the type to an ArrayList which would work but ideally I want to have a typed list.
Cheers for any help,
Paul
Here is my class:
<Serializable()> _
Public Class MessagePrompt
Implements ISerializable
Public _name As String
' this is the problem...
Public _actions As List(Of String)
Public Sub New()
End Sub
Public Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
Try
Trace.WriteLine("MessagePrompt.New: Deserializing")
_actions = CType(info.GetValue("Actions", GetType(List(Of String))), List(Of String))
Trace.WriteLine("MessagePrompt.New: There are " & _actions.Count & " actions")
Catch ex As Exception
Trace.WriteLine("MessagePrompt.New: Exception encountered deserializing.")
Trace.WriteLine(ex.ToString())
End Try
End Sub
Public Sub GetObjectData(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext) Implements System.Runtime.Serialization.ISerializable.GetObjectData
Trace.WriteLine("MessagePrompt.GetObjectData: Serializing")
' comment this line and all works fine!!!!!! except that
' the values I need will not come across the wire unless I use
' array list.
info.AddValue("Actions", _actions, GetType(List(Of String)))
End Sub
End Class
modified on Tuesday, February 3, 2009 5:46 AM
|
|
|
|
|
I'm trying to test how my app will behave with a hardened CAS policy. Since I don't want to affect any other applications I tried to create a custom code group underneath users-All_code. I picked application directory as the membership condition, but can't find where to specify what the directory used is.
Since I've never messed with CAS policy before, I assume there's something I'm not getting; but don't know what.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
|
I'll keep that title n mind if we go from Maybe to Will on having to implement some hardening constraints. ATM I'm trying to find out what a few settings do and how much, if any, impact switching from default to locked down will have.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
Kindly tell me what is N-hypernet and usage with sample code or refer any link plz..
|
|
|
|
|
kamakshim wrote: Kindly tell me what is N-hypernet and usage with sample code or refer any link plz..
I have no idea. However there is thing called the internet and it contains information services called search engines. You can type stuff into those search engines and they go off and search for things. Neat, huh!
Here is a demonstration of how to use one of those search engines, a popular one, called the "Google". How to search the "Google" for N-hypernet[^]
|
|
|
|
|
Should I click that link? Or will Google's cold hard reality burst my dreams of the sheer awesomeness of what I imagine an N-HYPERNET to be?
Zoooooooom! Oh boy, zap those n-internets through the hypertubes! Whee! I am going to send an internet to my staff next friday, and it got here TODAY!
|
|
|
|
|
I've never heard of N-hypernet. Is it remotely possible that you're thinking of NHibernate?
|
|
|
|
|
ya sorry by mistakely typed, kindly explain about this
|
|
|
|
|
It's an Object Relational Mapper (ORM) - you can find a sample here[^].
|
|
|
|
|
Hi,
I've jest upgraded from VS-2005 to VS-2008.
When I try to run any of my old projects I gett the following exeption:
"Configuration system failed to initialize"
With the inner exception:
{"Unrecognized configuration section system.serviceModel. (C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\Config\\machine.config line 137)"}
Line 137 in this file configures the ststem.web:
<system.web>
<processModel autoConfig="true"/>
<httpHandlers/>
<membership>
<providers>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
</providers>
</membership>
<profile>
<providers>
<add name="AspNetSqlProfileProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</profile>
<roleManager>
<providers>
<add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<add name="AspNetWindowsTokenRoleProvider" applicationName="/" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</roleManager>
</system.web>
As all of my projects use an auto updater which uses a web service, i assume it has somthing to do with ASP.NET configuration...
Any ideas?
tnx
Roy
|
|
|
|
|
Hi All, (using Vb.net & VS 2008)
I have the following problem which has stumped me for the last few days :
I have a form with a Datagridview showing products ordered by customers over a 14 day period.
Also on the form I have an external combo box. The combo box is populated with customer names.
My plan is to have the user select a customer name via the external combo box then have the datagridview filtered with orders for the selected customer for the 14 days
So far, this is what is happening :
The Datgridview displays orders for All customers correctly over 14 days
The combo box displays a drop down list of All customers correctly
So far this is not happening :
Selecting a customer from the combo box doesn't change the datagridview to show only the selected customer orders. Orders from all customers show regardless of which customer is in the combo box selection.
Here is the code I am using :
-----------------------------------------------------------------------------------------------
Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
Dim connection As SqlCeConnection = New SqlCeConnection()
connection.ConnectionString = "Data Source=\SD Card\DB.sdf;"
connection.Open()
'Populate the orders datatable from the Order table
Dim da As SqlCeDataAdapter = New SqlCeDataAdapter("SELECT my select statement goes here", connection)
Dim mybindingsource As New DataTable
da.Fill(mybindingsource)
DataGridView1.DataSource = mybindingsource
'Populate the Combo Box with Cust ID & Names from the Account table
Dim cboda As SqlCeDataAdapter = New SqlCeDataAdapter("SELECT ID, AccountName FROM Account", connection)
Dim cbods As DataSet = New DataSet
cboda.Fill(cbods, "Account")
Dim dt As New DataTable
dt.Columns.Add("ID", GetType(System.String))
dt.Columns.Add("AccountName", GetType(System.String))
Dim drcbods As DataRow
Dim drNewRow As DataRow
For Each drcbods In cbods.Tables("Account").Rows()
drNewRow = dt.NewRow()
drNewRow("ID") = drcbods("ID")
drNewRow("AccountName") = drcbods("AccountName")
dt.Rows.Add(drNewRow)
Next
cboCustomers.DropDownStyle = ComboBoxStyle.DropDownList
With cboCustomers
.DataSource = New DataView(dt)
.DisplayMember = "AccountName"
.ValueMember = "ID"
End With
-------------------------------------------------------------------------------------
I have the following code under the Combo box selectedValueChanged event
Private Sub cboCustomers_SelectedValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboCustomers.SelectedValueChanged
Me.myBindingSource.Filter = "Account_ID= '" & cboCustomers.SelectedValue.ToString & "'"
-------------------------------------------------------------------------------------
Fields in the Order datatable are : Account_ID, AccountName, Product_ID, ProductName, OdrQty1,......OrdQty14
Fields in the Account datatable are : ID, AccountName
In the underlying DB the Account and Order tables are linked via Account.ID = Order.Account_ID
I greatly apperciate any advice or assistance.
Many Thanks
Ku Mungi
|
|
|
|
|
Have you tried to used DataView[^] class as your datasource. Filtering is quite easy with that.
|
|
|
|
|
Thanks for the reply, I will check out the DataView class as suggested.
|
|
|
|
|
Mika Wendelius wrote: Have you tried to used DataView[^] class as your datasource. Filtering is quite easy with that.
I now have this working perfectly with a dataview and linq statement.
Thanks for pointing me in the right direction. Cheers
K
|
|
|
|
|
You're welcome
|
|
|
|
|
Hello everyone there,
I have following two problem with vb.net2005
1. I am trying to create a setup file for my application. I created the setup project(by adding setup and deployment project to my existing workspace),and without making any change(or chacking any option) I build the setup project. But when I try to install the created SETUP exe it pops up an error "the folder path '.' contains an illegal character"
Could anyone please help me out with the problem.
2. Also please give me the basic option to select (or to take care), while deploying a project. I am using vb.net2005 with crystal report.
Thanks in advance
I am a learner Always
|
|
|
|
|
|
Do not cross-post. It's considered rude.
|
|
|
|
|
I'm working on a utility that will allow the user to query some data from a database and output it.
I would like to support allowing the user to provide a format for the numbers, particularly if hexadecimal representation is desired.
Ideally I could simply do ((System.IFormattable) datarow [ columnname ]).ToString ( format , null ) , but when hexadecimal is requested the user may (should) want to tack on a leading "0x" and I've been unable to form a format that will do that.
What should work is "'0x'X4" , the '0x' should be copied to the output and then the value should be formatted with X4.
From the documentation:
"
'ABC' "ABC"
Literal string
Characters enclosed in single or double quotes are copied to the result string, and do not affect formatting.
"
Bull-pucky; they do affect formatting, they screw it up!
The closest I've gotten is string.Format ( format , datarow [ columnname ] ) with a format of "0x{0:X4}", but the user shouldn't need to specify the braces and such.
I'm considering using a Regular Expression and pre-processing the format to remove literal text before passing it to ToString, and concatenating the thing back together afterward.
I'm hoping someone here has a better solution.
|
|
|
|
|
The format characters you use should be enclosed with {}. I think there's nothing you can do about it.
I think the main question is what kind of options do you want to offer to the user? For example if you want to use syntax like:
"Hex, 4"
That would be converted using something like the following (with proper checks for the syntax):
If (format.StartsWith("hex", StringComparison.InvariantCultureIgnoreCase)) {
formatString = string.Format("0x{{0:X{0}}}",
int.Parse(format.Substring(format.IndexOf(',') + 1)))
}
|
|
|
|
|
Mika Wendelius wrote: enclosed with {}.
That's only with string.Format and its ilk. Which, as I said, works, but isn't ideal; the user would need to know too much about the internal workings of the program.
I could also just not support hex; after all, the database won't display the values that way.
I could also not allow a width specifier.
I could have hex and width specified separately.
On the other hand, this is just one simple utility; in the future I may have a project that really requires this.
I'd much prefer to use ToString and allow the user to specify "any valid Custom Numeric Format String[^]"
That should offer the greatest flexibility with the least intervention on my part. And it should work, according to the documentation.
I'll investigate my RegularExpression idea some time today. Thanks for your response.
|
|
|
|
|
PIEBALDconsult wrote: And it should work, according to the documentation
I'm pretty sure it works. Although I haven't used it so that the user gives the format, I read the format typically from database and it works fine.
PIEBALDconsult wrote: I'll investigate my RegularExpression idea some time today
Possibly the best way to go.
PIEBALDconsult wrote: Thanks for your response
No problem.
|
|
|
|
|
Mika Wendelius wrote: I read the format typically from database
For this utility I'll get it via XML file, but the user who creates the file should be able to specify what he wants without knowing much about the internal plumbing.
An added bonus to how I envision working around this problem responding pro-actively to this opportunity is that I can allow multiple sub-formats in the format.
With string.Format I can use "{0:X4}={0}" to format the same value into the output twice, but ToString doesn't seem to support that on its own: 20.ToString ( "X4'='0" ) results in X4=20 .
But if I pre-process the format, I can add support that I feel ToString should have; split the format into { "X4" , "'='" , "0" } , then iterate and if the sub-format is literal text, output it (Append to a StringBuilder), otherwise pass the sub-format to ToString and output the result.
The resultant process should then better match how I understand ToString should work with custom numeric formats.
|
|
|
|
|
|