.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Cannot send List inside of Dictionary

Posted By:      Posted Date: September 08, 2010    Points: 0   Category :WCF
List<string> receivers = new List<string>(); foreach (object item in listBoxControl1.SelectedItems) receivers.Add((string)item); Dictionary<string, object> inArgs = new Dictionary<string, object>(); inArgs.Add("Receivers", receivers); inArgs.Add("Sender", client.name); inArgs.Add("Message", memoEdit2.Text); inArgs.Add("IsGuaranteedDelivery", true); inArgs.Add("DataType", TransmitToClientDataType.ChatMessage); if (service != null) service.AddTask("orion_send", inArgs); There is an error with serialization at last string because List<string> object. I tryed to send List<T> object via WCF, it's succesfull. But why there are problems with List<T> included to Dictionary?

View Complete Post

More Related Resource Links

Keep updating Session object with a new List c#


I have a Session object

Session["MyListObjects"] = null;

When a user hits a button I want to creat a List<string> object and add to session object.

Let's say if user hits the button 10 times, I would get 10 List<string> objects and
add to Session["MyListObjects"] and

Finally I want to read all the List<string> objects from the session object.

Please let me know how to do that.

How to send an email with information in query string


First I will say I googled (Binged to make Bill happy) for this but could not find anything, perhaps I am not stating what I need correctly;

I have a website that a customer creates orders (for a printing company) and after the order, I would like to email the customer a link to view the status of their order;

I need to send the CustomerID in the link so on the returning page if a CustomerID is detected in the querystring, I "auto login" the client and open the "Dashboard" for the order page for that customer.

Can anyone point me in the right direction as to how to send the link and how to parse the querystring to get the values from the link;

Thank you if you can point me in the right direction.

.Sort a List problem



I have a little problem with sorting a List<String>.

I have put 4 elements like this and now are trying sort them correct. My example below shows the problem. I am not sure of how sort the names so they comes in this order: "Folder1, Folder2, Folder10, Foler11"  ?

List<String> GetNames = new List<String>();

GetNames .Add("Folder1");
GetNames .Add("Folder10");
GetNames .Add("Folder2");
GetNames .Add("Folder11");

GetNames.Sort(); //Sort the list

The sort comes in this order now which is wrong:

How to sort the list to have this order: ?



How to read a column of a sharepoint list to a text string field of infopath form?

My infopath form used to read these email addresses from a web service and web.config file. Now i would like to get these user email addresses from a contact list in a sharepoint server. I am trying to do this without writing any codes. Here is what i have done so far: 1. Adding a new "data connection to receive data from SharePoint library or List" where i selected Email Address column of the contact list. 2. I added a new Text Field and define a new rule with "Query using a data connection" defined above. When i try to access the newly created Text field above it always return empty as if the Query attached to it did not executed at all. What did i do wrong? Is there a better way? Thank you in advance for your help.

ComboBox Display list does not update if a datasource is a boxed string

I have a combo box databound to a BindingSource bound to a List<Holder> it has Holder.Name as its display value. I also have a text box bound to Holder.Name but if I change the text in the text box it will not change what is displayed in the combo box. Changing selected items and changing back will show the updated text in the text box but will still have the old value displayed in the combo box. How do I make the item in the combo box update? namespace Sandbox_Form { public partial class Form1 : Form { public Form1() { InitializeComponent(); lstBroken = new List<Holder>(); lstBroken.Add(new Holder("test1")); lstBroken.Add(new Holder("test2")); bsBroken = new BindingSource(lstBroken, null); cmbBroken.DataSource = bsBroken; cmbBroken.DisplayMember = "Name"; txtBroken.DataBindings.Add("Text", bsBroken, "Name"); lstWorks = new List<string>(); lstWorks.Add("test3"); lstWorks.Add("test4"); bsWorks = new BindingSource(lstWorks, null); cmbWorks.DataSource = bsWorks; txtWorks.DataBindings.Add("Text", bsWorks, null); } } public class Holder { public Holder(string name) { Name = name; } public string Name { get; set; } } }

How to Sort a List

Hi, I have  aList<String> with textFiles. I wonder how it is possible to sort this List<String> so the  textFiles gets in order starting with the lowest number to the highest number. Now the order is like this and below the example is the sorted order I after to achieve: ( .Sort() does not sort it in this order)List<String> Listing = new List<String>(); Listing.Add("1.txt"); Listing.Add("23.txt"); Listing.Add("12.txt"); Listing.Add("3.txt"); Listing.Add("2.txt"); //Sort so the above list have this order ? Listing.Add("1.txt"); Listing.Add("2.txt"); Listing.Add("3.txt"); Listing.Add("12.txt"); Listing.Add("23.txt");    

how to count the occurence of a perticular string inside a string.

I have 1000 rows in a table with 20 columns. One of the column has Resource wjich is character data type and values can be eithe General Information, Success Stories and which can be separated by commas and can be repeated multiple times in a row. I want to find out  how many times Success Stories repeats in a perticular row Eg:  In the below row  string Sucess Stories repeats 2 times. So I should get the count as 2.  General Information,Success Stories,White Papers, Sucess Stories Can anyone please help to write sql for the above logic.   Thanks  

Order list by string value

Hi, I need to order a list of items, by a string value...e.g. 635, 955, 5820, 1010 should appear as 635,955,1010,5820, however it shows up as 1010, 5820, 635, 955 because it's a string and not an integer.I cannot convert to integer, it must eb a string value. Any suggestions as to how this can be done simply using a string value?

Passing an List to my Action

    public ActionResult RenderMyThing(IList<String> strings)     {         return View("RenderMyView");     }     Somebody will come to my page, RenderMyThing.aspx ... and I always want to pass a list of strings         routes.MapRoute("MyRoute", "RenderMyThing.aspx", new { controller = "My", action = "RenderMyThing", new List<String> { ... } });    Is this possible?

How to String to Array List

i have a string like   S=""but i want string to convert to Arraylist Ar[0]=1;Ar[1]=2;

Weird Issue with the MOSS Search : FileExtension metadata object type instead of string

Hello, We 've got a strange issue with the search and especially with the FileExtension metadata. when we make a query on the search engine, we receive for the FileExtension metadata an unexcpected result. here is a printscreen showing the issue. http://cid-53eee937847a625e.photos.live.com/self.aspx/Public/Untitled.jpg as you can see the Type of the FileExtension is object and it should be string and I checked the type of the object and it's System.String[] the element at the index 0 contains the value! what's wrong ? thx in advance

Html.DropDownList using a List

This has to be a simple thing, but for whatever reason, I'm just not finding it. I want to use the HTML Helper function to create a DropDownList based on a List<string> (and actually have it bind to the data field on the model).  The simplest example, I suppose, would be: <%: Html.DropDownList("Material", new SelectList(new[] {"Wood","Brick","Metal"})) %> This creates the items in the drop-down, but of course, there's nothing in this line that would bind it to my model (model.Material).  I've done drop-downs with collections of models, where you can bind the Data and Display attributes to properties of the class, but I don't have a class here, just a List. Any ideas?

how to get a class reference as a reference and not a string to send for a generic method

I got some property that i get using generic method, there for I dont have it's <T>and I want to send it to another generic method but , how the heck do I get it's <T> :P?please look at the code below to understandit gets an entity framework objects, scan all it's properties and if the property is another entity framework object it would send it back to him self , the issue is that i dont know the new object <T> to send it back to him self :(search for the bold part to see what i'm missing//contains objects which we added so there wont be double adding private List<object> _addedObjects; public FakeGenericRepositoryExtension() { _addedObjects = new List<object>(); } public void Create<T>(T entity) where T : class { //add to created objects _addedObjects.Add(entity); //do something with object //... //start recircle process Type entityType = typeof(T); //run thrue each member of Type foreach (var member in typeof(Type).GetProperties()) { //get member value var member_value = member.GetValue(entity, null); //if not null //we must test this otherwise we can't get .BaseType if (member_value != null) { //get current member's base type string memberBaseType = member.GetValue(entity, null).GetType().BaseTyp

Unable to cast object of type 'System.Guid' to type 'System.String'.

protected void Button1_Click(object sender, EventArgs e) { using (BurnbetDataContext dc = new BurnbetDataContext()) { var q = (from c in dc.GetTable<tbl_Payment>() where c.ID == 5 select c).Single<tbl_Payment>(); dc.GetTable<tbl_Payment>().DeleteOnSubmit(q); dc.SubmitChanges(); } } }System.InvalidCastException was unhandled by user code  Message=Unable to cast object of type 'System.Guid' to type 'System.String'.  Source=System.Data.Linq  StackTrace:       at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)       at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)       at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)       at System.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression)&nb

converting a rdr object to a string


I inherited some code and I need to change a line so that instead of testing to see if the value in a table column is not null, it also tests to see if the value is not empty.

The existing line is:

if (rdr["InnLinkURL"] != null)

"InnLinkURL" is the name of the column being tested.

I thought a solution could be something like:

if (String.IsNullOrEmpty(InnLinkURL) == true)

Not sure how to convert the object to a string, though.

public static string ToString(
 object value

If someone could show me the proper syntax I'd be grateful.

As an alternative, I tried this also but it doesn't seem to work (no errors, just doesn't return true)

if ((rdr["InnLinkURL"] != null) && (rdr["InnLinkURL"] != ""));

Unable to cast object of type 'System.DBNull' to type 'System.String'.


 I saw lots of post about this issue. but haven't got good solution for that yet. Basically, what I did is that: I have a table in SQL database and some of data fields allow null. I built Objectdatasource through dataset. When I built update page using dataset. It generate the following error before showing the update page correctly. It seems I have issue to retrieve the null value from the database through using objectdatasource through dataset. Any suggestions?




Error attached below:

Unable to cast object of type 'System.DBNull' to type 'System.String'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.String'.

Source Error:

Line 1178:            get {
Line 1179:                try {
Line 1180:                    return ((string)(this[this.tablemember.CurrentCityStateColumn]));
Line 1181:                
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend