Click here to Skip to main content
15,887,998 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to use annotation in flowdocument reader but showing runtime error.code Given below..

C#
this.stream = new FileStream("storage.xml", FileMode.OpenOrCreate);
/*storage.xml used by another process */
           this.service = new AnnotationService(this.flowRdr1);
           this.store = new XmlStreamStore(this.stream);
           this.store.AutoFlush = true;
           this.service.Enable(this.store);
           // Detect when annotations are added or deleted
           this.service.Store.StoreContentChanged += new StoreContentChangedEventHandler(AnnotationStore_StoreContentChanged);
           // Bind to annotations in store
           BindToAnnotations(this.store.GetAnnotations());
Posted
Updated 31-Jul-12 15:30pm
v2

1 solution

The error means what it says. If you're debugging, an older process is not finished with it. The fact you don't close your stream is part of the issue here. Use a using statement, close your stream as soon as you can. Otherwise, while this code has it open, no other code can see it. Your code means that even if you run this code twice on the one machine, in debugging, the old one may not have been closed, and so you get this error.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900