DLL resource problem
Daniel Hooymans -- dhooymans@hotmail.com
Thursday, November 28, 1996
Environment: VC40 WINNT3.51
Hi,
perhaps you could help me out a little,
I created a DLL (not an MFC (dll)) which contains the following function:
void doparse(FILE * fpIn, FILE * fpOut)
// the fpIn and fpOut are opened input and output
{
...
}
I created an MFC dialog app wich uses the DLL-function when I push a button on
the dialog form. I included a header file with the prototype of the parse
function. And added the lib file to my Dialog project.
The problem I have will only arise when I try to do a getc(fpIn) in the
DLL-function. The program will get a General protection error. But when I do a
getc(fpIn) in the application where I created and opened the file pointers, it
works alright.
The filepointers do have the correct data when I check the params in the DLL
function.
After I traced the getc() function I saw that in the function the FILE* is
checked if it's inside a array called _iob[] (contains possibly the
io-streamhandles). In the MFC dialog app the _iob[] is a different _iob[] as
the _iob[] in the MFC Dialog app.
The app checks the _iob[] to see if the filestream is locked.
Because there are two different _iob[] arrays I get the problem.
So I know the problem but I don't know the answer.
In my assumption:
The DLL links with the MSVCRT lib.
The MFC dialog app links with the MSVCRT lib too but this is another instance.
I really need streams, because I want to be able to stream a string to the
parse function.
If anyone could help me, please.
Thanks in advance,
Daniel
---------------------------------------------------------
Get Your *Web-Based* Free Email at http://www.hotmail.com
---------------------------------------------------------
Eddie Stassen -- stasseed@telkom.co.za
Monday, December 02, 1996
I came across the similar problem using strstream with the C++ standard
libraries. In my original application the App would create a strstream
and pass it to the DLL which would then write to the stream. This work
fine until I changed to the C++ standard libraries. The problem in
this case seemed to with the runtime library which maintains some
static pointers to internal data which are different between the app
and the DLL.
The only solution I could find was to let my DLL create/open the stream
for me and pass pointers to buffers across instead of stream refs.
>>> "Daniel Hooymans" 28/November/1996 06:42pm
>>>
Environment: VC40 WINNT3.51
Hi,
perhaps you could help me out a little,
I created a DLL (not an MFC (dll)) which contains the following
function:
void doparse(FILE * fpIn, FILE * fpOut)
// the fpIn and fpOut are opened input and output
{
...
}
I created an MFC dialog app wich uses the DLL-function when I push a
button on
the dialog form. I included a header file with the prototype of the
parse
function. And added the lib file to my Dialog project.
The problem I have will only arise when I try to do a getc(fpIn) in the
DLL-function. The program will get a General protection error. But when
I do a
getc(fpIn) in the application where I created and opened the file
pointers, it
works alright.
The filepointers do have the correct data when I check the params in the
DLL
function.
After I traced the getc() function I saw that in the function the FILE*
is
checked if it's inside a array called _iob[] (contains possibly the
io-streamhandles). In the MFC dialog app the _iob[] is a different
_iob[] as
the _iob[] in the MFC Dialog app.
The app checks the _iob[] to see if the filestream is locked.
Because there are two different _iob[] arrays I get the problem.
So I know the problem but I don't know the answer.
In my assumption:
The DLL links with the MSVCRT lib.
The MFC dialog app links with the MSVCRT lib too but this is another
instance.
I really need streams, because I want to be able to stream a string to
the
parse function.
If anyone could help me, please.
Thanks in advance,
Daniel
---------------------------------------------------------
Get Your *Web-Based* Free Email at http://www.hotmail.com
---------------------------------------------------------
Michael Schneider -- Michael.Schneider@datev.de
Wednesday, December 04, 1996
There can be some other reasons for this problem:
1) You link the static MFC. In this case you use different runtimes.
2) Maybe one part is a debug version the other one a release version.
I don't know if this can be a problem with the runtime too, but in
MFC
it is (because virtual functions are conditionally inserted in
the debug version).
3) There can be a problem with static variables between the DLL and the
EXE. There is a technical note about that problem (search for
_dllimport).
Maybe one of these reasons is the reason of your problem.
Regards, Michael
===================================================
Michael Schneider
Pirckheimer Weg 13
91058 Erlangen
Germany
Phone: ++49 9131 771539
E-Mail: Mike.Schneider@fim.uni-erlangen.de
Mike.Schneider@t-online.de
WWW: http://home.t-online.de/home/Mike.Schneider
===================================================
Peter Moss -- pmoss@bbn.com
Tuesday, December 17, 1996
I had this problem too. I found the answer in the MSDN "PRB: File Handles
Cannot Be Shared Between Programs or DLLs". It is found in PSS ID Q46524.
Pete Moss
_________________________________________________________________
Environment: VC40 WINNT3.51
Hi,
perhaps you could help me out a little,
I created a DLL (not an MFC (dll)) which contains the following function:
void doparse(FILE * fpIn, FILE * fpOut)
// the fpIn and fpOut are opened input and output
{
...
}
I created an MFC dialog app wich uses the DLL-function when I push a button on
the dialog form. I included a header file with the prototype of the parse
function. And added the lib file to my Dialog project.
The problem I have will only arise when I try to do a getc(fpIn) in the
DLL-function. The program will get a General protection error. But when I do a
getc(fpIn) in the application where I created and opened the file pointers, it
works alright.
The filepointers do have the correct data when I check the params in the DLL
function.
After I traced the getc() function I saw that in the function the FILE* is
checked if it's inside a array called _iob[] (contains possibly the
io-streamhandles). In the MFC dialog app the _iob[] is a different _iob[] as
the _iob[] in the MFC Dialog app.
The app checks the _iob[] to see if the filestream is locked.
Because there are two different _iob[] arrays I get the problem.
So I know the problem but I don't know the answer.
In my assumption:
The DLL links with the MSVCRT lib.
The MFC dialog app links with the MSVCRT lib too but this is another instance.
I really need streams, because I want to be able to stream a string to the
parse function.
If anyone could help me, please.
Thanks in advance,
Daniel
Martin J. Mahoney -- mjm@PyramidLogicSystems.com
Friday, December 20, 1996
I have not used this in a DLL but the Standard C library provides two
functions that
might help you.
int _fileno(FILE *stream) : Takes an open stream and returns the OS
file descriptor. No errors are returned.
You can use this function to convert your stream to a file descriptor
before calling the DLL and
inside the DLL you can use:
FILE *_fdopen(int handle, const char *mode) : This takes a file descriptor
and associates
it to a stream.
To convert the descriptor back to a stream.
Hope this helps
Martin J. Mahoney
Pyramid Logic Systems
http://www.PyramidLogicSystems.com
----------
> From: Peter Moss
> To: mfc-l@netcom.com
> Cc: dhooymans@hotmail.com
> Subject: Re: DLL resource problem
> Date: Tuesday, December 17, 1996 1:14 PM
>
> I had this problem too. I found the answer in the MSDN "PRB: File Handles
> Cannot Be Shared Between Programs or DLLs". It is found in PSS ID Q46524.
>
> Pete Moss
> _________________________________________________________________
>
> Environment: VC40 WINNT3.51
>
> Hi,
>
> perhaps you could help me out a little,
>
> I created a DLL (not an MFC (dll)) which contains the following function:
>
> void doparse(FILE * fpIn, FILE * fpOut)
> // the fpIn and fpOut are opened input and output
> {
> ...
> }
>
> I created an MFC dialog app wich uses the DLL-function when I push a
button on
> the dialog form. I included a header file with the prototype of the parse
> function. And added the lib file to my Dialog project.
>
> The problem I have will only arise when I try to do a getc(fpIn) in the
> DLL-function. The program will get a General protection error. But when I
do a
> getc(fpIn) in the application where I created and opened the file
pointers, it
> works alright.
>
> The filepointers do have the correct data when I check the params in the
DLL
> function.
>
> After I traced the getc() function I saw that in the function the FILE*
is
> checked if it's inside a array called _iob[] (contains possibly the
> io-streamhandles). In the MFC dialog app the _iob[] is a different _iob[]
as
> the _iob[] in the MFC Dialog app.
>
> The app checks the _iob[] to see if the filestream is locked.
>
> Because there are two different _iob[] arrays I get the problem.
> So I know the problem but I don't know the answer.
>
> In my assumption:
> The DLL links with the MSVCRT lib.
> The MFC dialog app links with the MSVCRT lib too but this is another
instance.
>
> I really need streams, because I want to be able to stream a string to
the
> parse function.
>
> If anyone could help me, please.
>
> Thanks in advance,
>
> Daniel
| Вернуться в корень Архива
|