You know I was wondering the same thing. Although it's odd that it makes it through exactly 30 rows every single time before it errors out. I was also thinking that because the author switches the memory stream from one of two other memory streams, that maybe the main memory stream is being overridden before a read is complete....
formatter.Deserialize(s) assumes that the entire object has been successfully written to the stream? For grins and giggle, try writing the entire stream to memory after 30 rows; I bet a dime to a dollar, all of your strings have not been completely written. At least that is what I would look into, don't know the answer myself as I completely avoid WCF like the plague.
Of course it's possible! The problem is how do YOU define "similar". Once you have that, YOU have to write the code to get the currently selected text in the textbox, then search the textbox contents for the "similar" works.
When I try to serialize an object using xmlserializer,It is throwing out of memory exception.Is there any way to serialize large objects like more than 30 mb. I am able to serialize an object to xml file only if the size of the file after serialization is around 15 mb otherwise outofmemory exception is thrown
Hi all, can someone please clear things up for me regarding inheriting an abstract class. According to msdn.com[^] the following are some of the features of an abstract class:
It is not possible to modify an abstract class with the sealed modifier, which means that the class cannot be inherited.
A non-abstract class derived from an abstract class must include actual implementations of all inherited abstract methods and accessors.
The first sentence says that the class cannot be inherited but the second sentence says you can have a non-abstract class which is derived from an abstract class. If I'm not mistaken, a derived class is a class that inherits from another class. Thanks in advance for your response.
MSDN isn't always right and sometimes, like here, they don't update the documentation. If you follow the 'other versions' links, at the top of that page, to VS 2012, you'll see that the stuff about 'abstract sealed' has been changed.
It's possible that the person who wrote the docs was confusing C# and intermediate language (IL) classes. When a C# static class is compiled to IL, the class declaration is marked as abstract and sealed. So a C# static class is equivalent to an IL abstract sealed class.
In C# it's not actually possible to declare a class as 'abstract sealed'. Try it and you'll find that it won't compile.
I agree that this sentence could be clearer. What they're trying to say is:
You cannot add the sealed modifier to an abstract class;
The sealed modifier means that a class cannot be inherited;
It looks like they cleared this up in the VS2010 version[^], where the sentence has been changed to:
It is not possible to modify an abstract class with the sealed (C# Reference) modifier because the two modifers have opposite meanings. The sealed modifier prevents a class from being inherited and the abstract modifier requires a class to be inherited.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
In a C# 2008 application, I used linq to sql to connect to a sql server 2008 database. Now I want to obtain the connection of the database from the
app.config file instead of hardcoding the value into the application. I want to be able to change the connection string to the database since I will be moving this application from unit testing database to user acceptance database to the the prodction database.
Right now I am getting the error message, ""Object reference not set to an instance of an object." I know this error message is coming from the line of code that I listed below since it is the only line of code I changed.
The following is a snippet of the code from the *.designer.cs file (this is part of the dbml file).
public esampleDataContext() :
**Note: base(global::sample.Properties.Settings.Default.DEVConnectionString, mappingSource) is the line of code that I replaced that was generated by the
I want to mention the following:
1. The *.dbml file is associated with a particular project file.
2. The connection string settings for this *.dbml file are the following:
a. DEVConnectionString (settings)
b. Connection String = Data Source=dev1;Initial Catalog=DEV_test;Integrated Security=True
c. application settings=True
d. settings property name is DEVConnectionString.
3. The project file that has the *.dbml file. has a reference set to the system.configuration.
**Note: This code in similar applications that I wrote, but I do not why it does not work here.
Thus can you tell me, show me in code, and/or point me to a reference that I can use so I can obtain the value in the app.config file for the database connection string I want to use. I do not want to use a hard-coded connection string to the database.
point me to a reference that I can use so I can obtain the value in the app.config file for the database connection string I want to use. I do not want to use a hard-coded connection string to the database.
Correct me if I'm wrong, but isn't the connectionstring in the app.config file? Isn't the app.config file an XML file that can be edited?
If both answers are yes, then your connectionstring isn't hardcoded, but loaded from the settings-file.
The problem is the settings-file does not get the value from the app.config file. The values are retained in the settings-file from the time I orginally created the app.config file. The settings-file needs to change at some point.
Your app.config needs to be set up in a very specific way for that to work.
If it isn't set up that way then ConnectionStrings will be null.
I would suggest that you do the following
1. Create a project/app that ONLY gets the connection string
2. Create a app.config that ONLY has that connection string.
3. Verify in that app that ConnectionStrings is not null before using it.
4. Get the connection string property and print it.
Then if that doesn't work then you can post the entire class and the entire app.config. Do not include real info in the app.config all you care about is that it get a value not what is in it.
I am using Visual 2010 and sap crystal report 2010. When displayed on the report is correct, but when exported to excel from report tool does not display properly.Have you asked yourself how to fix it. Thanks!
I created a new WinForms project and got this error:
The designer could not be shown for this file because none of the classes within it can be designed.
I have not yet added any code to the project. It appears as if all of the necessary assemblies are referenced, but intellisense can't seem to resolve the Form class.
Shutting VS2012 down and starting it back up again solved the issue. Weird.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
Maybe the fact that I mentioned WPF when the OP was looking for ASP.NET was the reason. I don't see how my answer was wrong in that context as you could esily substitute the WPF front end with a ASP.NET version (or have both, and....).
I don't speak Idiot - please talk slowly and clearly
If the topic isn't something you are interested in, or have knowledge of, then you will give up on it and that won't help you. Find something that interests you and use that as a basis of your project.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
First of all this is wrong place to ask this question. Such question could be asked in GIT or Lounge.
Secondly, I appreciate the intention that you have behind posting this question i.e. learning but perhaps(like others said) you should be able to come up with some ideas on your own.
thirdly, my suggestion would be to start small application like contact book/address book or small forums. but keep in mind that your sole focus should be on learning various concepts related to C# and ASP.NET than just getting your project done.
Every now and then say, "What the Elephant." "What the Elephant" gives you freedom. Freedom brings opportunity. Opportunity makes your future.
I am trying to convert the string to datetime including the milliseconds... unfortunately when I used the Convert.ToDateTime method, it does not return the milliseconds... I have tried the parse and parseExact method in the Datetime and DateTimeOffset classes as well... none of them returning the milliseconds... I read the previous discussion regarding this issue and none of the solutions return the milliseconds...This is what I am trying to do:
Thank you so much for taking your time to respond to my post... I really appreciate it... but the solution both of you mentioned does not work for my situation... may be I did not state my question clearly... I apologize for that...
Pete, in your solution, you are converting the date to string again... that's not what i want...
And BMS121, I used the 'TimeOfDay' property as you suggested , but I could not assign that to datetime variable... I get compiler error :'Cannot implicitly convert System.TimeSpan to System.Datetime...
This is what I want to accomplish:
I am getting the datetime as a string from client ... so I have to convert that string to datetime including millisecond and then I have to store/save that datetime in the database (the datebase column is datetime type)...
Here is the code snippet:
string strDate = "2012-11-09 07:20:07.410"
Datetime actualDate = Convert.ToDateTime(strDate); -(L2)
L2 : does not return millisecond...
As per BMS121 suggestion, I tried the following :
(my entity object is called EDEntitiy)
Edentity.Timestamp = actualDate.TimeOfDay;
But above statement causes compiler error:
'Cannot implicitly convert System.TimeSpan to System.Datetime...
You are misunderstanding Pete's solution. Convert.ToDateTime is already giving you the right answer, but the default ToString on a DateTime omits the milliseconds, so it looks like it isn't when you look at the string representation of the DateTime you create. If you format it with milliseconds, you'll see that you got what you expected.
Thanks. Really appreciate it. My issue is this.
string strDate = "2012-11-09 07:20:07.410"
Datetime actualDate = Convert.ToDateTime(strDate);
Now when I save this date (actualDate) in the database(I am using the Entity Frame work to connect to the database), this is what i see in the database : 2012-11-09 07:20:07.000
As you can see, the millisecond is zero in the database... so my question is how do I save date (after converting from string to datetime) with milliseconds... my datebase date column is SQL datetime type...