Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / February 2008

Tip: Looking for answers? Try searching our database.

file already locked in mixed C++/CLI code?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
emarkp - 13 Feb 2008 19:48 GMT
I'm using an aging library that I can't port to .Net.  It reads a file
and parses it into a structure.

The problem I'm having is that in a mixed assembly (/clr) when I call
the library, it returns an error saying the file is locked.  Problem
is, it only gets locked when I try to load the file.

I can replicate the problem with fopen--the open fails saying the file
is already locked, but it's fopen that's trying to lock it in teh
first place.

Has anyone run into this?  Is there a general solution?
David Lowndes - 14 Feb 2008 08:04 GMT
>I'm using an aging library that I can't port to .Net.  It reads a file
>and parses it into a structure.
>
>The problem I'm having is that in a mixed assembly (/clr) when I call
>the library, it returns an error saying the file is locked.  Problem
>is, it only gets locked when I try to load the file.

If you're not making use of the file elsewhere there's no reason why
it should fail - so the question is where else is it getting accessed?
Have you had a look at what's happening with the SysInternals FileMon
utility?

Dave
emarkp - 19 Feb 2008 22:01 GMT
> >I'm using an aging library that I can't port to .Net.  It reads a file
> >and parses it into a structure.
[quoted text clipped - 9 lines]
>
> Dave
emarkp - 19 Feb 2008 22:04 GMT
> If you're not making use of the file elsewhere there's no reason why
> it should fail - so the question is where else is it getting accessed?
> Have you had a look at what's happening with the SysInternals FileMon
> utility?

It's not getting accessed elsewhere. When running FileMon, it's the
only process accessing the file, and it reports a successful open and
then close.  Something in the library is reporting a failure.  When I
compile the module as native code, it works fine.
David Lowndes - 20 Feb 2008 00:46 GMT
>> If you're not making use of the file elsewhere there's no reason why
>> it should fail - so the question is where else is it getting accessed?
[quoted text clipped - 5 lines]
>then close.  Something in the library is reporting a failure.  When I
>compile the module as native code, it works fine.

OK, can you supply a self-contained source example (a small console
project) that illustrates the problem?

Dave
emarkp - 20 Feb 2008 01:08 GMT
> OK, can you supply a self-contained source example (a small console
> project) that illustrates the problem?

Afraid not. It's a proprietary library. All I'm doing is providing the
filename to the library entry point.

As it stands, we've found an an alternate library and (with source)
and it looks like we'll just be ditching this lib.
Sheng Jiang[MVP] - 15 Feb 2008 19:19 GMT
How you access the files in .Net? Are you disposing the disposable objects?
Signature

Sheng Jiang
Microsoft MVP in VC++

> I'm using an aging library that I can't port to .Net.  It reads a file
> and parses it into a structure.
[quoted text clipped - 8 lines]
>
> Has anyone run into this?  Is there a general solution?
emarkp - 19 Feb 2008 20:10 GMT
On Feb 15, 12:13 pm, "Sheng Jiang[MVP]"
<sheng_ji...@hotmail.com.discuss> wrote:
> How you access the files in .Net? Are you disposing the disposable objects?

I'm performing all directory and file listing operations using the
File:: and Directory:: static functions. I'm not using the objects,
precisely to avoid unnecessary locking.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.