06-25-2021 12:37 PM
Bill,
Now that you say that, yes. I'm using the FileSystemWatcher (mscorlib.dll) to watch files as they come in so I can consume them as they are placed in a directory.
I also remember a post about the GC.Collect method(?) needing to be called for something as .NET doesn't do proper garbage collection in LV - or something like that - so that will force it to occur. I am not doing that when I destroy the watcher.
Eric
06-25-2021 12:54 PM
That FileSystemWatcher is a very good suspect. The GC Collect shouldn't be necessary to make things safe. That is more related to callback VIs staying locked as there is still a .Net context referencing them and your FileSystemWatcher of course will use callback VIs (or did you rather register the .Net Event as a LabVIEW user event, which works too)?
In any case using .Net events is always a bit tricky since you often have a .Net side of the event that needs to be explicitly destroyed with a Destroy() or Close() call and also a LabVIEW side of the event that needs to be properly closed too. In the case of events registered as user events you have in fact the Unregister first and then the LabVIEW Refnum close for the event itself. And correct order of closing/deallocation can matter here for sure!
06-25-2021 03:49 PM
Bill,
To make sure I understand, I should:
06-25-2021 05:36 PM
@Eric1977 wrote:
Bill,
To make sure I understand, I should:
- Dispose of the File System Watcher
- Close the Reference to the watcher
- Unregister for the Events REfrum
- Destroy the User Event
- Unregister the Events from the Event Callback Refrum
I think rolfk is much more qualified to answer this than me. Sorry! 😞
06-26-2021 09:53 AM
As to the order of how to dispose things I think the example from the linked article should be ok.
1) Unregister user event registration refnum
2) Destroy User event
3) FileSystemWatcher.Dispose()
4) Close FileSystemWatcher
5) Unregister Event Callback refnum
06-28-2021 04:40 PM
rolfk,
The Access Violations came from a Access Database that I was using for a test db. The connection string looked good based on what I saw on ConnecctionStrings.com. Once I switched it over to SQL Server (which we have a sandbox area where we can test things like this) the access violations went away.
Have you, or anyone else, heard of these violations happening to Access Databases? I have Office 365 with Access installed on my PC. Curious is all.
06-29-2021 01:55 AM
@Eric1977 wrote:
Have you, or anyone else, heard of these violations happening to Access Databases? I have Office 365 with Access installed on my PC. Curious is all.
I haven't used Access in probably 20 years. It's not really a database in many aspects. And office applications through ActiveX interface are troublesome at best in respect to mixing and matching between 32-bit and 64-bit. With them nowadays being almost exclusively installed as 64-bit version, you are bound to run into trouble if you try to access them from 32-bit application such as many LabVIEW installations still are.
Not that it couldn't be done. (D)COM, which is at the base of ActiveX is perfectly capable of bridging that gap (if the component is properly registered to do that) because of its inherent almost fully transparent data marshalling through out of process invocation of the ActiveX server component. But that requires a strict discipline in developing and registering such components, and that is something almost nobody does anymore in the modern days of "everything is .Net", especially from Microsoft who have all their bets 120% on .Net and are more than happy to let ActiveX drop from the radar ASAP.
07-01-2021 07:54 AM
Never even gave the bitness a thought but sounds like that very well could be the issue. And Microsoft's continued massaging.
I'll put my post as the solution about Access being the culprit. I'll have to remember that for next time. Have a good 4th of July weekend.