Hello,
I’m having issues when I try to create an instance of an activeX which manages an Access Control.
I got an .ocx file which I imported to the project and I developed the Access Control in a similar way to the ‘Demo Access Control’ but when I try to create an Access Control from my plugin installed I get the following error:
ActiveX control ‘X’ cannot be instantiated because the current thread is not in a single-threaded apartment
I googled a bit and tried to create the instance (in the …AccessControlSystem.cs) in a different thread:
var t = new Thread(() {
myOcxController = new OcxController()
});
t.SetApartmentState(ApartmentState.STA);
t.Start();
But then the ‘Event server’ crash every time I try to test it.
Did anyone face this or similar problem? How can I fix it?
Thanks in advance
An ActiveX cannot be used in a service (no UI element).
You would have to have your application with activeX run in its own and communicate with an Access Control plugin in the Event Server.
So i guess i need to do a ‘component integration’ instead of an ‘plugin integration’ and run my own end user application?
I have been looking on the Milestone docs and i have seen this ActiveX mentioned there.
Im new in the Milestone world so i would appreciate if you can also answer this question.
Thanks in advance
If you look at the Demo Access Control Plug-in sample, you will see how this implements a Event Server plugin that communicate with an external program emulating a access control system, perhaps this will fit with having your application externally.
Using the Access Control frame-work in the MIP SDK an Event Server plug-in is required.
https://doc.developer.milestonesys.com/html/index.html?base=samples/acplugin.html&tree=tree_1.html
https://doc.developer.milestonesys.com/html/index.html?base=gettingstarted/intro_accesscontrol.html&tree=tree_4.html