- Home /
how to release dlls?
Hi,
Now I'm making an USB-camera application. In this app, I use mydll for camera management. mydll's run() written in 'C' manages usb camera. Actually it worked well, I confirmed camera capture window worked as the unity's background task. But when I restarted app with unity's GUI editor, camera window didn't start and only unity app worked. So this app only works well at first time. In this case, I have to restart unity program. And I confirmed that mydll was occupied even if I stopped my app in unity.
So I think I have to load dll modules dynamically for this problem. And I have to release them when app stops. Is it correct? Are there anyone help? please let me know...
[DllImport("mydll", CharSet = CharSet.Auto)]
private static extern int run();
private static Thread t;
// Use this for initialization
void Start () {
t = new System.Threading.Thread(new System.Threading.ThreadStart(this.start));
t.Start();
}
private void start()
{
run(); //usb camera program
}
Answer by JKLs · Nov 23, 2011 at 11:50 AM
I implemented dynamic dll import script like below link. And I confirmed dll lock problem was resolved by FreeLibrary(handle) method. I can delete my dll while unity editor was runnning. This is checking for the lock problem.
But I'm still facing same problem about usb camera. For the first start-up, I succeed to run usb camera. but from next time camera doesn't start-up.
Is my problem related to below? http://forum.unity3d.com/threads/79587-DLL-Lock
Please let me know if you know something..