Can't find PInvoke DLL - BUG?

G

Guest

Hi,
i have strange problem using PIvoke.

When i call function from native library i get "Can't find PInvoke DLL"
error sometimes.
The .dll is located in the same directory as app.
When i restart system, then it works fine.

It seems to like that os can't see or access library file on some
circumstances...

have anyone expirienced such behaviour?
 
C

Christian Resma Helle

Have you tried placing the DLL you want to P/Invoke in the \Windows folder?
How does your code look like?
 
G

Guest

My code where i use method from zlibce.dll:
Error: "Can't find PInvoke DLL 'zlibce.dll'"

....

private static int Uncompress(byte[] dest, ref int destLen, byte[] src, int
srcLen)
{
if (Environment.OSVersion.Platform == PlatformID.WinCE)
return uncompressCE(dest, ref destLen, src, srcLen);
else
return uncompress(dest, ref destLen, src, srcLen);
}

#region zlib.dll
[DllImport("zlib1.dll")]
private static extern int compress(byte[] dest, ref int destLen, byte[] src,
int srcLen);

[DllImport("zlib1.dll")]
private static extern int uncompress(byte[] dest, ref int destLen, byte[]
src, int srcLen);

[DllImport("zlibce.dll", EntryPoint = "compress")]
private static extern int compressCE(byte[] dest, ref int destLen, byte[]
src, int srcLen);

[DllImport("zlibce.dll", EntryPoint = "uncompress")]
private static extern int uncompressCE(byte[] dest, ref int destLen, byte[]
src, int srcLen);
#endregion

....

I am getting same error when using another dll (my own) - the usage is quite
similat except that there is no platform switch (only for CE).

I did not tried to move dlls to \Windows jet - problem is, that this error
is very irregular - it happend only once on our testing environment, but it
happens more often to our customer.

Is there any difference when loading library from app. directory and from
\Windows directory?
 
P

Paul G. Tobey [eMVP]

I don't have a Windows Mobile device in front of me, but are you sure that
the DLL name is ZLIBCE.DLL? I think maybe ZLIB.DLL is more likely, as
that's what its name is in generic WindowsCE.

Paul T.

Michal Rizek said:
My code where i use method from zlibce.dll:
Error: "Can't find PInvoke DLL 'zlibce.dll'"

...

private static int Uncompress(byte[] dest, ref int destLen, byte[] src,
int
srcLen)
{
if (Environment.OSVersion.Platform == PlatformID.WinCE)
return uncompressCE(dest, ref destLen, src, srcLen);
else
return uncompress(dest, ref destLen, src, srcLen);
}

#region zlib.dll
[DllImport("zlib1.dll")]
private static extern int compress(byte[] dest, ref int destLen, byte[]
src,
int srcLen);

[DllImport("zlib1.dll")]
private static extern int uncompress(byte[] dest, ref int destLen, byte[]
src, int srcLen);

[DllImport("zlibce.dll", EntryPoint = "compress")]
private static extern int compressCE(byte[] dest, ref int destLen, byte[]
src, int srcLen);

[DllImport("zlibce.dll", EntryPoint = "uncompress")]
private static extern int uncompressCE(byte[] dest, ref int destLen,
byte[]
src, int srcLen);
#endregion

...

I am getting same error when using another dll (my own) - the usage is
quite
similat except that there is no platform switch (only for CE).

I did not tried to move dlls to \Windows jet - problem is, that this error
is very irregular - it happend only once on our testing environment, but
it
happens more often to our customer.

Is there any difference when loading library from app. directory and from
\Windows directory?


Christian Resma Helle said:
Have you tried placing the DLL you want to P/Invoke in the \Windows
folder?
How does your code look like?
 
G

Guest

This can occur if you are out of virtual memory and the DLL cannot be
loaded.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
 
G

Guest

It's definitely named correctly - we created it. :)

www.OpenNETCF.com/zlibce

-Chris



"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
I don't have a Windows Mobile device in front of me, but are you sure that
the DLL name is ZLIBCE.DLL? I think maybe ZLIB.DLL is more likely, as
that's what its name is in generic WindowsCE.

Paul T.

Michal Rizek said:
My code where i use method from zlibce.dll:
Error: "Can't find PInvoke DLL 'zlibce.dll'"

...

private static int Uncompress(byte[] dest, ref int destLen, byte[] src,
int
srcLen)
{
if (Environment.OSVersion.Platform == PlatformID.WinCE)
return uncompressCE(dest, ref destLen, src, srcLen);
else
return uncompress(dest, ref destLen, src, srcLen);
}

#region zlib.dll
[DllImport("zlib1.dll")]
private static extern int compress(byte[] dest, ref int destLen, byte[]
src,
int srcLen);

[DllImport("zlib1.dll")]
private static extern int uncompress(byte[] dest, ref int destLen, byte[]
src, int srcLen);

[DllImport("zlibce.dll", EntryPoint = "compress")]
private static extern int compressCE(byte[] dest, ref int destLen, byte[]
src, int srcLen);

[DllImport("zlibce.dll", EntryPoint = "uncompress")]
private static extern int uncompressCE(byte[] dest, ref int destLen,
byte[]
src, int srcLen);
#endregion

...

I am getting same error when using another dll (my own) - the usage is
quite
similat except that there is no platform switch (only for CE).

I did not tried to move dlls to \Windows jet - problem is, that this
error
is very irregular - it happend only once on our testing environment, but
it
happens more often to our customer.

Is there any difference when loading library from app. directory and from
\Windows directory?


Christian Resma Helle said:
Have you tried placing the DLL you want to P/Invoke in the \Windows
folder?
How does your code look like?

--
Regards,
Christian Resma Helle
http://christian-helle.blogspot.com


Hi,
i have strange problem using PIvoke.

When i call function from native library i get "Can't find PInvoke
DLL"
error sometimes.
The .dll is located in the same directory as app.
When i restart system, then it works fine.

It seems to like that os can't see or access library file on some
circumstances...

have anyone expirienced such behaviour?
 
G

Guest

You might try forcing a load earlier in the applciation (manually call
LoadLibrary or make a P/Invoke call to it at startup). However if the
device (is this by chance a PPC Phone Edition?) has very little virtual
memory and the users have a lot of other stuff going that is eating up what
little there is, there's not much you can do short of asking them to close
other apps or doing it for them. I'd be inclined to at least try
broadcasting a WM_HIBERNATE on failure and trying again just to see if that
helps mitigate the issue.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com



Michal Rizek said:
My code where i use method from zlibce.dll:
Error: "Can't find PInvoke DLL 'zlibce.dll'"

...

private static int Uncompress(byte[] dest, ref int destLen, byte[] src,
int
srcLen)
{
if (Environment.OSVersion.Platform == PlatformID.WinCE)
return uncompressCE(dest, ref destLen, src, srcLen);
else
return uncompress(dest, ref destLen, src, srcLen);
}

#region zlib.dll
[DllImport("zlib1.dll")]
private static extern int compress(byte[] dest, ref int destLen, byte[]
src,
int srcLen);

[DllImport("zlib1.dll")]
private static extern int uncompress(byte[] dest, ref int destLen, byte[]
src, int srcLen);

[DllImport("zlibce.dll", EntryPoint = "compress")]
private static extern int compressCE(byte[] dest, ref int destLen, byte[]
src, int srcLen);

[DllImport("zlibce.dll", EntryPoint = "uncompress")]
private static extern int uncompressCE(byte[] dest, ref int destLen,
byte[]
src, int srcLen);
#endregion

...

I am getting same error when using another dll (my own) - the usage is
quite
similat except that there is no platform switch (only for CE).

I did not tried to move dlls to \Windows jet - problem is, that this error
is very irregular - it happend only once on our testing environment, but
it
happens more often to our customer.

Is there any difference when loading library from app. directory and from
\Windows directory?


Christian Resma Helle said:
Have you tried placing the DLL you want to P/Invoke in the \Windows
folder?
How does your code look like?
 
P

Paul G. Tobey [eMVP]

Cool. zlib.dll in Windows CE has the same function name in it, so I thought
maybe I had it...

Paul T.

It's definitely named correctly - we created it. :)

www.OpenNETCF.com/zlibce

-Chris



"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
I don't have a Windows Mobile device in front of me, but are you sure that
the DLL name is ZLIBCE.DLL? I think maybe ZLIB.DLL is more likely, as
that's what its name is in generic WindowsCE.

Paul T.

Michal Rizek said:
My code where i use method from zlibce.dll:
Error: "Can't find PInvoke DLL 'zlibce.dll'"

...

private static int Uncompress(byte[] dest, ref int destLen, byte[] src,
int
srcLen)
{
if (Environment.OSVersion.Platform == PlatformID.WinCE)
return uncompressCE(dest, ref destLen, src, srcLen);
else
return uncompress(dest, ref destLen, src, srcLen);
}

#region zlib.dll
[DllImport("zlib1.dll")]
private static extern int compress(byte[] dest, ref int destLen, byte[]
src,
int srcLen);

[DllImport("zlib1.dll")]
private static extern int uncompress(byte[] dest, ref int destLen,
byte[]
src, int srcLen);

[DllImport("zlibce.dll", EntryPoint = "compress")]
private static extern int compressCE(byte[] dest, ref int destLen,
byte[]
src, int srcLen);

[DllImport("zlibce.dll", EntryPoint = "uncompress")]
private static extern int uncompressCE(byte[] dest, ref int destLen,
byte[]
src, int srcLen);
#endregion

...

I am getting same error when using another dll (my own) - the usage is
quite
similat except that there is no platform switch (only for CE).

I did not tried to move dlls to \Windows jet - problem is, that this
error
is very irregular - it happend only once on our testing environment, but
it
happens more often to our customer.

Is there any difference when loading library from app. directory and
from
\Windows directory?


:

Have you tried placing the DLL you want to P/Invoke in the \Windows
folder?
How does your code look like?

--
Regards,
Christian Resma Helle
http://christian-helle.blogspot.com


Hi,
i have strange problem using PIvoke.

When i call function from native library i get "Can't find PInvoke
DLL"
error sometimes.
The .dll is located in the same directory as app.
When i restart system, then it works fine.

It seems to like that os can't see or access library file on some
circumstances...

have anyone expirienced such behaviour?
 
G

Guest

It sounds interesting - it realy could be memory issue.
I will try to trace some memory usage stats and see what's up.

Thank you
 
G

Guest

Yep, the zlib in CE however is a really old version (complete with the bugs
and security problems).

-Chris


"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
Cool. zlib.dll in Windows CE has the same function name in it, so I
thought maybe I had it...

Paul T.

It's definitely named correctly - we created it. :)

www.OpenNETCF.com/zlibce

-Chris



"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message news:[email protected]...
I don't have a Windows Mobile device in front of me, but are you sure
that the DLL name is ZLIBCE.DLL? I think maybe ZLIB.DLL is more likely,
as that's what its name is in generic WindowsCE.

Paul T.

My code where i use method from zlibce.dll:
Error: "Can't find PInvoke DLL 'zlibce.dll'"

...

private static int Uncompress(byte[] dest, ref int destLen, byte[] src,
int
srcLen)
{
if (Environment.OSVersion.Platform == PlatformID.WinCE)
return uncompressCE(dest, ref destLen, src, srcLen);
else
return uncompress(dest, ref destLen, src, srcLen);
}

#region zlib.dll
[DllImport("zlib1.dll")]
private static extern int compress(byte[] dest, ref int destLen, byte[]
src,
int srcLen);

[DllImport("zlib1.dll")]
private static extern int uncompress(byte[] dest, ref int destLen,
byte[]
src, int srcLen);

[DllImport("zlibce.dll", EntryPoint = "compress")]
private static extern int compressCE(byte[] dest, ref int destLen,
byte[]
src, int srcLen);

[DllImport("zlibce.dll", EntryPoint = "uncompress")]
private static extern int uncompressCE(byte[] dest, ref int destLen,
byte[]
src, int srcLen);
#endregion

...

I am getting same error when using another dll (my own) - the usage is
quite
similat except that there is no platform switch (only for CE).

I did not tried to move dlls to \Windows jet - problem is, that this
error
is very irregular - it happend only once on our testing environment,
but it
happens more often to our customer.

Is there any difference when loading library from app. directory and
from
\Windows directory?


:

Have you tried placing the DLL you want to P/Invoke in the \Windows
folder?
How does your code look like?

--
Regards,
Christian Resma Helle
http://christian-helle.blogspot.com


message
Hi,
i have strange problem using PIvoke.

When i call function from native library i get "Can't find PInvoke
DLL"
error sometimes.
The .dll is located in the same directory as app.
When i restart system, then it works fine.

It seems to like that os can't see or access library file on some
circumstances...

have anyone expirienced such behaviour?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top