|
Chris Losinger wrote: the reader closes the file just fine if everything works. it clearly knows how to close the file that it opened without any assistance from me.
As I said before, if it knows that you can't use it any more, it can close the file. If you don't read the file to the end, it won't know this, and it doesn't know your opinion of when it can be closed.
Chris Losinger wrote: i don't expect it to keep reading at all - it threw an exception. if it could keep reading, it should've just kept reading.
As I said before, just because there is an exception it doesn't automatically mean that you can't continue to read from it. You just chose not to, and the reader is not aware of your decision as you haven't told it.
---
b { font-weight: normal; }
|
|
|
|
|
Guffa wrote: if it knows that you can't use it any more, it can close the file. If you don't read the file to the end, it won't know this, and it doesn't know your opinion of when it can be closed.
it opened the file. if i wanted control of the file outside of the context of an XmlReader, i would've created a StreamReader and gave that to the XmlReader. but i didn't - i gave XmlReader a filename and it opened the file. let me repeat that: XmlReader opened the file.
Guffa wrote: You just chose not to, and the reader is not aware of your decision as you haven't told it.
my decision was made by the fact that i called the thing via the interface that implies "here, you handle the file operations, not me". i didn't give it an opened file. i gave it a filename.
i didn't say "open this file, do what you need, then leave it open for me", i gave it a filename. and, the XmlReader provides no way to get to that opened file once it's opened it, so your statement that i can "continue to read from it" is completly meaningless - XmlReader provides no access to the opened file stream.
|
|
|
|
|
Chris Losinger wrote: it opened the file. if i wanted control of the file outside of the context of an XmlReader, i would've created a StreamReader and gave that to the XmlReader. but i didn't - i gave XmlReader a filename and it opened the file. let me repeat that: XmlReader opened the file.
Yes, you asked the reader to open the file. If you tell it to close it, it will. If you don't tell it to close it but leave it hanging in the middle of the process, it can't close the file as it doesn't know that you don't want to continue reading from it.
If you don't tell the reader that you don't want to use the file any more, how do you expect it to close the file?
my decision was made by the fact that i called the thing via the interface that implies "here, you handle the file operations, not me". i didn't give it an opened file. i gave it a filename.
Yes, and it does handle the file operations, according to the information that you give to the reader. If the reader has no information that you are done reading from the file, it can't close it.
i didn't say "open this file, do what you need, then leave it open for me"
Yes, you did. You opened it and stopped reading in the middle. Of course it stays open until you complete the read or closes it.
the XmlReader provides no way to get to that opened file once it's opened it, so your statement that i can "continue to read from it" is completly meaningless - XmlReader provides no access to the opened file stream.
It's not meaningless at all. You read from the file using the methods of the reader, it's irrelevant if you have direct access to the file or not.
It's exactly the same as with a stream. You use the methods of the stream to read from a file, but you never have direct access the the file.
---
b { font-weight: normal; }
|
|
|
|
|
Guffa wrote: If you don't tell the reader that you don't want to use the file any more, how do you expect it to close the file?
the exact same way it does when it finishes without an exception. why is that so hard for you to understand ?
|
|
|
|
|
Chris Losinger wrote: the exact same way it does when it finishes without an exception. why is that so hard for you to understand ?
I understand how you wish that it would work. I want you to explain how in the world you can expect it to work that way?
I have already told you that the reader can't close the file until you tell the reader that you don't want to use it any more. If you just leave it hanging halfway through the read, it doesn't know that you have decided not to read anything more.
It's just like if you pack up your car to go to Alaska, but halfways you run into a roadblock telling you to take another route. If you just step out of the car, leave it running and go to find a bar instead, the car won't figure out that you don't want to drive any further and shut itself down. It will just keep waiting until it runs out of gas.
The same thing happens to the reader that you left hanging. It will just keep waiting until the garbage collector comes and tells it to pack up and go.
---
b { font-weight: normal; }
|
|
|
|
|
|
Chris Losinger wrote: that's just silly. surely you can see the difference between a function called "File.Open" and one called "XmlReader.Create".
For my last 10+ years of C++ and C# development both a Create and Open interface will open a file. Open opens an exising file and File.Create creates a new file which is then opened.
Chris Losinger wrote: at best, this function is inconsistent in behavior and poorly-documented
It may be poorly documented, but it is consistent with my last 10+ years of experience with a Microsoft development framework.
|
|
|
|
|
Your right about the class being poorly documented. It's not a bug with the class, but with the people who wrote it.
In the XmlReader class, there is, thankfully, a property called ReadState that you can check in your code to see if the was actually opened or not. The possible values are Closed, EndOfFile, Error, Initial, and Interactive. Docs on it are here[^].
You can either use Guffa's version or just call the Dispose() method on the XmlReader in your catch block. If the file hasn't been opened, nothing will happen if you call Dispose on the reader.
-- modified at 10:56 Friday 6th October, 2006
Changed Close to Dispose. That's what I get for spending entire day and night writing in VBScript...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dave Kreskowiak wrote: a property called ReadState that you can check in your code to see if the was actually opened or not
ah. that's good to know. thanks.
|
|
|
|
|
Hello all,
I'm using .NET 2005 and I have to convert a collection (CustomCollection) into a List, from Generics. I don't seem to find anything about it... Has anybody any idea if it is possible to do this conversion without copying every object from the collection to the list (only a conversion) and if it's possible... how should i do that??
Please help...
Thank you!
Roxana
|
|
|
|
|
Hi,
basically you will have to copy the contents. You could make this by either copying everything yourself or by using the CopyTo method of the collection to copy everything into an array and than either using the appropriate List constructor (one of them takes any IEnumerable) or using AddRange.
Robert
|
|
|
|
|
I get the following error when compiling some of the projects in my solution but not all.
'A strong-named assembly is required. (Exception from HRESULT: 0x80131044)'
Can someone tell me what this means and provide some suggestions on how to resolve this?
thanks,
eric
|
|
|
|
|
|
hi,
i have two different projects. One project dll is required in another project's bin. But i cannot add a reference because of cross reference. Is there any way where after i compile the solution automatically the dll from one project gets copied in another project's bin? Currently i have a batch file which does this job. Can i integrate this bat file with my .net IDE so that it executes everytime after i compile?
Its bye for now..
Signing off.
Seshu
|
|
|
|
|
Look in the Project Properties, Compile options, Build Events. You can execute your batch file from there.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi
I am using static binding i.e the use of dll of MS OUTLOOK 2003 in my Windows application to extract FROM,TO,CC,BCC,MESSAGE email addresses and their names etc. and store it into an MS ACCESS database. The module is working fine in my machine and also in client machines, but some of the clients are complaining that they are getting the error at the time of running the module. They are also using MS Office Outlook 2003. They are getting the error when try to run the application.
The error is like this:
System.IO.FileNotFoundException: The specified module could not be found.
I think sometimes CLR fails to load unmanaged dll of OUTLOOK. I have tried by using most of things but till now there is no success. All the dlls are present in applications root folder.
Is there any idea?
regards
|
|
|
|
|
You could try using the fusion log generated by fuslogvw[^]. You can track which assembly is missing and then figure out if any of its (managed or unmanaged) dependencies are missing.
|
|
|
|
|
Thanks for your reply.
I had used FUSLOGVW.exe and got the log below but still it is unsolved. Please give some suggestions.
*** Assembly Binder Log Entry (10/5/2006 @ 5:20:22 PM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\fusion.dll
Running under executable D:\Projects\TestApp\bin\Debug\TestApp.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = TestApp.resources, Version=1.0.2470.31203, Culture=en-US, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = D:\Projects\TestApp\bin\Debug\
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : TestApp, Version=1.0.2470.31203, Culture=neutral, PublicKeyToken=null.
===
LOG: Processing DEVPATH.
LOG: DEVPATH is not set. Falling through to regular bind.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Post-policy reference: TestApp.resources, Version=1.0.2470.31203, Culture=en-US, PublicKeyToken=null
LOG: Attempting download of new URL file:///D:/Projects/TestApp/bin/Debug/en-US/TestApp.resources.DLL.
LOG: Attempting download of new URL file:///D:/Projects/TestApp/bin/Debug/en-US/TestApp.resources/TestApp.resources.DLL.
LOG: Attempting download of new URL file:///D:/Projects/TestApp/bin/Debug/en-US/TestApp.resources.EXE.
LOG: Attempting download of new URL file:///D:/Projects/TestApp/bin/Debug/en-US/TestApp.resources/TestApp.resources.EXE.
LOG: All probing URLs attempted and failed.
Regards
|
|
|
|
|
The log shows that TestApp.resources assembly is not present in the assembly probing paths. You need to make sure that assembly is present in one of the paths from which fusion is attempting to download the file.
|
|
|
|
|
Thanks for your reply.
From where will I get TestApp.resources assembly? There is no resource files are required for my project.
regards
|
|
|
|
|
How can add a new item in popup of a browser ?
or How can change it's items ?
computer
|
|
|
|
|
By items you mean what?
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
I'm working on a program that takes some files from one VSS database, does something with them and puts them into another VSS database.
Everything was working until I triedy my program on a VSS project that had labels defined.
My code searches for the latest version of a file. And if a file has some versions and a label which is the newest, I get the version number of that label. And I can't get a file based on the label. I need the latest version of a file even if the latest thing is a label.
I would like to know if there is a way to exclude labels from the collection that get_Versions returns or how can I find out if the current version object (inside a foreach loop) is a label.
My code looks something like that (relevant part that is):
System.Collections.IEnumerator versions = vssFile.get_Versions ( 0 ).GetEnumerator ();
versions.MoveNext ();
int latestVersion = ((IVSSVersion)versions.Current).VersionNumber;
latestVersionFile = vssFile.get_Version ( latestVersion );
string saveFileName = savePath + "\\" + latestVersionFile.Name;
latestVersionFile.Get ( ref saveFileName, 0 );
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
Dose anybody know how its possible to get a traffic used by specified process pid or name ?
|
|
|
|
|
No, it's not. Those statistics don't exist anywhere, unless the application itself is keeping track of them.
You could, on the other hand, attach performance counters to the process and start monitoring them yourself, but those stat's don't exist "automatically" when you start a new process.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|