|
Hello, I'm having trouble with a dll. It crashes(freeze) on the second test. This is probably because the dll cannot be loaded twice (it communicates with drivers), and Unity does not unload when I stop testing. I found this command: but it gives this error: Assets/TestScript.cs(76,17): error CS0103: The name `FreeLibrary' does not exist in the current context Does anyone have an idea how I can use FreeLibrary, because I can't find the dependency for it. I'm using Unity 3.1 with Windows 7. Thanks :) Siewart
(comments are locked)
|
|
I do not believe that such a function exists in mono as it is not cross-platform and I can find no such function with the API. According to MSDN, FreeLibrary is a function defined in Winbase.h. I'm pretty sure you cannot or should not be trying to use it in this context. I feel that you are correct in that your dll usage is likely failing to release certain needed resources, but I am not certain if it is because the dll is not unloaded although it may well be the case. I know that I find it frustrating to be working on a dll and to have to restart Unity in order to remove the write protection placed on the dll if I ever run my game from the editor. This write protection indicates that Unity still has the dll loaded and depending on what that entails, it may be driving your problem but, in my experience, every time a dll I was using in Unity crashed, it was my own fault rather than some resources being tied up by having the dll loaded. Did you consider that perhaps your dll is either doing something erroneous or being used erroneously? Are you using threading and when you stop execution, do you ensure that all threads are terminated first? Do you allocate any resources that you don't free up? Without more details on the dll and its usage, I can only guess at what might be wrong in the event that it is not because the dll is still loaded. Hey thanks for your quick reply. I am using the CLNUIDevice.dll (http://www.nuigroup.com/forums/viewthread/11249/) with a Kinect. But I cant work on this project, because there is a new Kinect driver available, and I can't have both drivers installed at the same time... I have checked with Process Explorer if the dll was loaded on testing the app, and checked if it was unloaded after that. I also use the Stop and Destroy functions to stop the connections with the Kinect. -Siewart
Dec 12 '10 at 01:17 PM
Siewart
I do not feel it is a problem of not unloading the dll as I (and others) have dlls in use and can start and stop the game preview in the editor any number of times without crashing. If crashing were the behaviour when a dll was not unloaded, then everyone would experience it. I think that the dll allocates some resources with CreateNUIMotor and CreateNUICamera and when you stop the game preview, your DestroyNUIMotor and DestroyNUICamera are not called, meaning that when you start the preview again, it tries to allocate the resources again. Try calling them in MonoBehaviour.OnApplicationQuit.
Dec 13 '10 at 03:54 PM
skovacs1
Sorry for my very late reply, a better Kinect framework has been released (openNI.org), but I haven't tried it yet, because the Kinect still is at the university. I already used this: But that doesn't work. (It is called, though) But it still crashes when I run it for the second time. Not sure if I still need an answer though. Thanks for your time
Jan 02 '11 at 02:41 PM
Siewart
(comments are locked)
|
