jacobbo / WebEye

WebEye is a collection of .NET controls.
190 stars 132 forks source link

temporary file problem #46

Open fastlink30 opened 6 years ago

fastlink30 commented 6 years ago

Winforms.WebCameraControl

start the camera like this, all ok webCameraControl1.StartCapture(...);

on FormClosing event stop the camera with webCameraControl1.StopCapture();

and then close the form, on dispose() i get this error System.UnauthorizedAccessException: 'Accesso al percorso 'C:\Users\rick\AppData\Local\Temp\tmp5E9F.tmp'

jacobbo commented 6 years ago

Are you using the latest version of the nuget package?

On Sat, 10 Mar 2018 at 09:27, fastlink30 notifications@github.com wrote:

Winforms.WebCameraControl

start the camera like this, all ok webCameraControl1.StartCapture(...);

on FormClosing event stop the camera with webCameraControl1.StopCapture();

and then close the form, on dispose() i get this error System.UnauthorizedAccessException: 'Accesso al percorso 'C:\Users\rick\AppData\Local\Temp\tmp5E9F.tmp'

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jacobbo/WebEye/issues/46, or mute the thread https://github.com/notifications/unsubscribe-auth/ABvfwFRtvz27ZsFDHtrpITqQsI9LawAQks5tc3JMgaJpZM4SlKeH .

fastlink30 commented 6 years ago

WebEye.Controls.WinForms.WebCameraControl v1.0.2 from nuget from references on project: Runtime version v2.0.50727 Win10

wilsoneden commented 6 years ago

I am also experiencing the same problem.

System.UnauthorizedAccessException: Access to the path 'C:\Users\DEV\AppData\Local\Temp\tmp707E.tmp' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.File.InternalDelete(String path, Boolean checkHost) at System.IO.File.Delete(String path) at WebEye.Controls.WinForms.StreamPlayerControl.StreamPlayerProxy.Dispose() in D:\dev\GitHub\WebEye\StreamPlayerControl\WinForms\StreamPlayerControl\StreamPlayerControl\StreamPlayerProxy.cs:line 164 at WebEye.Controls.WinForms.StreamPlayerControl.StreamPlayerControl.Dispose(Boolean disposing) in D:\dev\GitHub\WebEye\StreamPlayerControl\WinForms\StreamPlayerControl\StreamPlayerControl\StreamPlayerControl.cs:line 139 at System.ComponentModel.Component.Dispose() at System.Windows.Forms.Control.Dispose(Boolean disposing) at System.Windows.Forms.ContainerControl.Dispose(Boolean disposing)

It happens when the parent form of the control is disposed. I suppose it is trying to delete the temporary files. But then when the parent form is implemented with Using theForm ... End Using, it would then delete everything when the form disposes.

Please advice. Thank you.

jacobbo commented 6 years ago

that file C:\Users\DEV\AppData\Local\Temp\tmp707E.tmp could you please check its attributes? Is it readonly?

wilsoneden commented 6 years ago

that file does not exist whenever I check. I suspect it has been deleted when the parent form is disposed.

jacobbo commented 6 years ago

Also there is a mad suggestion that you're building it in Desktop folder: https://social.msdn.microsoft.com/Forums/vstudio/en-US/49676009-106c-41f9-ac29-8fb8954fad75/net-40-unauthorizedaccessexception-with-temp-or-appdata-folders?forum=vbgeneral

wilsoneden commented 6 years ago

I am not building it in Desktop folder. In fact, it is in folder C:\Users\Wilson Eden\Source\Repos\MyProject.

I've played around a bit more and found the file System.UnauthorizedAccessException: 'Access to the path 'C:\Users\Wilson Eden\AppData\Local\Temp\tmpA203.tmp' is denied.' and it is not read only.

I found a pattern where the error occurs is when we close the parent form before even the first NewFrame; or in other words, the control is still connecting to the camera (rtsp).

If I wait until the control has connected to the camera and closes the parent form, the error does not occur.

jacobbo commented 6 years ago

And if you run it as administrator, the issue goes away, doesn't it?

jacobbo commented 6 years ago

Also, can you reproduce the issue using the demo project?

wilsoneden commented 6 years ago

Same results when running it as administrator. Yes I get the same error using the demo WinForms project (although not always; 1 out of 4 produces the error).

In the StreamPlayerControl.cs:line 139

if (File.Exists(_dllFile))
{
    File.Delete(_dllFile);
}

what if we add a checking if the file can be deleted.

jacobbo commented 6 years ago

I do not think this is an authorisation issue, as the exception suggests. My idea is that FreeLibrary call does not release the dll and that is why File.Delete call fails. The most obvious solution for this would be to wrap File.Delete call in try/catch block. Another option is to keep calling FreeLibrary till the File.Delete call succeeds. I can send you binaries for the latter option.

Szanesz commented 3 years ago

Hello Team,

Im facing the same issue. every time it fails the tmp filename is different, C:\Users\Sanchez\AppData\Local\Temp\tmp6195.tmp C:\Users\Sanchez\AppData\Local\Temp\tmp2AE1.tmp It happens by more kind of trigger, not only at disposing the form.. when i run into a streamfailed or streamstopped event and i recall with webeye_1.StartPlay again it is success in most of the times, but if i run my app for hours it will definetly run into this TMP thing..

Im using the latest version of the nuget (1.0.6), WPF version, with vb.net. I am not building it in Desktop folder either. It comes if i run with admin too.

My knowledge is not enough to touch the suggested 'the StreamPlayerControl.cs:line 139' file... i have no idea how should i start that. I tried to put the .startplay into a trycatch but it didnt help either....

Can you please help me in this?

Thanks! Peter B (Hungary)

Szanesz commented 3 years ago

Hello

Adding one thing: i got the error one time at calling webeye_1.stop too.. i hope it helps to find the reason...

P.