473,769 Members | 3,923 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using serialization to serialize my objects to hard drive

Hey im using serialization to serialize my objects to hard drive,
reading them is no problem but overwriting them causes me problems,i
have un authorized access to the files but i gave the folder all the
permissions.

source:
http://www.vkarlsen.no/pastebin/default.asp?id=5545

can someone tell me what im not doing right

Nov 17 '05 #1
9 1831
this only occurs when i write a new file and then try to over write it.
if the thread finishes and starts overagain i am able to overwrite a
file that already exists as often as i want..

Nov 17 '05 #2

"Alexandre (www.pointnetso lutions.com)" <al************ *****@gmail.com >
wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Hey im using serialization to serialize my objects to hard drive,
reading them is no problem but overwriting them causes me problems,i
have un authorized access to the files but i gave the folder all the
permissions.

source:
http://www.vkarlsen.no/pastebin/default.asp?id=5545

can someone tell me what im not doing right


Please post the exact exception message.
You should also post the complete code that illustrates the problem you
have, not a few methods like you did now.

Willy.
Nov 17 '05 #3
In message <11************ **********@z14g 2000cwz.googleg roups.com>,
"Alexandre (www.pointnetso lutions.com)" <al************ *****@gmail.com >
writes
this only occurs when i write a new file and then try to over write it.
if the thread finishes and starts overagain i am able to overwrite a
file that already exists as often as i want..


Are you using a filestream to write to disk? Is it in a using block /
being cleaned up manually? The example below does not error. Remove the
'using' block, and you get a file locked exception:

"An unhandled exception of type 'System.IO.IOEx ception' occurred in
mscorlib.dll

Additional information: The process cannot access the file "I:\x.dat"
because it is being used by another process."

static void Main(string[] args)
{
WriteFile();
WriteFile();
Console.Read();
}
static void WriteFile()
{
Foo foo = new Foo();
BinaryFormatter bf = new BinaryFormatter ();
using(FileStrea m fs = new FileStream(@"I: \x.dat",FileMod e.Create))
{
bf.Serialize(fs ,foo);
}
}

--
Steve Walker
Nov 17 '05 #4
Additional information: The process cannot access the file "I:\x.dat"
because it is being used by another process."

is the exact error im getting this is all on a webservice, and i am
using the user statment "block" and i still get this error when i
create a new fresh file where i overwrite the file im alright.

it seems that when i create a new filei have to wait for the gc to
dispose of the application thread to release everything before i can
overwrite....

i find this quite strange because the code is clean and should work i
juste cannot find anything wrong with it.

if any one can give me some light on this i would be greatful...

Alexandre

Nov 17 '05 #5
In message <11************ **********@l41g 2000cwc.googleg roups.com>,
"Alexandre (www.pointnetso lutions.com)" <al************ *****@gmail.com >
writes
Additional information: The process cannot access the file "I:\x.dat"
because it is being used by another process."

is the exact error im getting this is all on a webservice, and i am
using the user statment "block" and i still get this error when i
create a new fresh file where i overwrite the file im alright.

it seems that when i create a new filei have to wait for the gc to
dispose of the application thread to release everything before i can
overwrite... .


I think you need to post the code.

--
Steve Walker
Nov 17 '05 #6
In message <11************ **********@z14g 2000cwz.googleg roups.com>,
"Alexandre (www.pointnetso lutions.com)" <al************ *****@gmail.com >
writes
i will post again :
http://www.vkarlsen.no/pastebin/ViewPaste.aspx?id=5563


That code works on my machine. Do you have another process locking it;
virus scanner, or index server, perhaps? You can use Process Explorer
http://www.sysinternals.com to find out which process has a file locked.

--
Steve Walker
Nov 17 '05 #8
i am using this code in a web service, therefore i truely have no idea
why it causes this problem like you have experienced this code works
great locally

Nov 17 '05 #9
If you are trying to write to a file from a webservice you may have threading
issues as multiple requests would be trying to write to the same file.

"Alexandre (www.pointnetso lutions.com)" wrote:
i am using this code in a web service, therefore i truely have no idea
why it causes this problem like you have experienced this code works
great locally

Nov 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
5430
by: Stuart Robertson | last post by:
I am trying to find a solution that will allow me to use XmlSerializer to serialize/deserialize a collection of objects where a given object is shared between two or more other objects, and not create duplicate XML representations of the shared object, but instead use IDREFs to refer to the shared object. The XML I'm trying to produce is as follows (where "href" is an IDREF): <?xml version="1.0" encoding="utf-8"?> <MyRootClass...
1
6003
by: Dim | last post by:
Hi! Kinda newbie to .NET nad got following question: Serializing objects in C#: I have a complex object that contains lots of data and other object including GraphicsPath, Point, Rectangle etc.. mostly from System.Drawing, System.Windows.Forms. When my object is constructed completelly and all graphics have been created
5
2368
by: Arjen | last post by:
Hello, Can somebody help me a little bit? I can't get it to work. Please see my code below... I have placed some comments like "// And whats next?". I'm sure that I have to code something here. But what? What do I want?
1
2338
by: oDDskOOL | last post by:
I realized today that the Hashtable.Clone only produces a shallow copy... that makes me go mad that M$ doesn't even provide a deep copy ctor for the Hashtable class ! mighty tech ducks might reply "oh but what if the types in hastable don't have copy ctors defined? that could lead to dangerous situations". well, but was it a significant effort to provide a copy ctor / deep clone method to this class for objects that provide the...
2
5046
by: jakk | last post by:
Below is the exception that Iam getting. It says that the DataView that Iam storing in the session is not Serializable. BUt works fine if I store in the inproc session and fails if I switch to storing the session in Sql Server. Please let me know if Iam doing anything wrong. Unable to serialize the session state. Please note that non-serializable objects or MarshalByRef objects are not permitted when
27
1948
by: Codemonkey | last post by:
Heya All, Sorry, but I think it's about time for a monkey-ramble. I've just had enough of trying to serialize even simple objects with VB. A simple task you may think - stick the <Serialized()> attribute on the class and away you go. As Homer would say - "D'Oh" The root of my problem lies in the way VB implements Events and the fact that you can't apply the <NonSerialized> attribute to the little rascals.
1
831
by: Peter Nofelt | last post by:
Hey All, I am having issue with serializing a class and its base class using ..net 2.0. I am using IXmlSerializable I've provided code displaying my at the bottom of this post. Thanks ahead of time for any help or feedback. Cheers, Peter
5
6718
by: googlenewsgroups | last post by:
I have a custom set of objects that is correctly serializing & deserializing the object tree. However in some cases the size of the resultant serialization is larger than I would expect. Is there any documented way to pull apart the stream to determine the sizes of the objects embedded within the file? For example if I open the file up in a Hex editor the 'containing' format looks reasonably simple to decode, but I would rather be coding...
8
12572
by: =?Utf-8?B?UGlnZ3k=?= | last post by:
Hi to all, I am getting this System.OutOfMemoryException calling the Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(<stream>,<Obj>) method. The type of <streamis IO.MemoryStream =====Exception: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10216
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9997
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5309
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.