I am trying to write web application in C# for ATEM Mini using their SDK. Finally i can switch video output, but only 5 times. After that, this error was showed:
The code where this error is looks like that
public AtemSwitcher()
{
IBMDSwitcherDiscovery discovery = new CBMDSwitcherDiscovery();
// Connect to switcher
discovery.ConnectTo("192.168.0.10", out IBMDSwitcher switcher, out _BMDSwitcherConnectToFailure failureReason);
this.switcher = switcher;
me0 = this.MixEffectBlocks.First();
}
The problem is in discovery. Had someone same problem or can someone help me?
-
1E_FAIL is but a teacher's grade for the quality of the error reporting. You'll have to ask DwainHans Passant– Hans Passant2023年04月04日 14:34:22 +00:00Commented Apr 4, 2023 at 14:34
-
I am trying to ask in their forum, but admin must approve the task and he is not one of the fastest.Tomáš Mejzr– Tomáš Mejzr2023年04月04日 15:01:10 +00:00Commented Apr 4, 2023 at 15:01
1 Answer 1
I don't know the details of that COM library. But, use of such in a webforms applications is probably not thread safe.
However, since it "fails" as a few uses?
this suggests you not disposing of the object. You want to do absolute "hand stands" and walk across the valley, the desert, the big valley, and then climb mountains to ensure that the object is disposed after you create, use it, and then are done.
As a result, then wrap your code in a using clause, as that will allow (force) .net to dispose of everything after you use it.
So, say like this (air code warning)
public void AtemSwitcher()
{
using (IBMDSwitcherDiscovery discovery = new CBMDSwitcherDiscovery())
{
// Connect to switcher
discovery.ConnectTo("192.168.0.10", out IBMDSwitcher switcher, out _BMDSwitcherConnectToFailure failureReason);
this.switcher = switcher;
me0 = this.MixEffectBlocks.First();
}
}
If the above using block does not help, then hit this with even a larger hammer.
Say this:
{
using (IBMDSwitcherDiscovery discovery = new CBMDSwitcherDiscovery())
{
// Connect to switcher
discovery.ConnectTo("192.168.0.10", out IBMDSwitcher switcher, out _BMDSwitcherConnectToFailure failureReason);
this.switcher = switcher;
me0 = this.MixEffectBlocks.First();
discovery.Dispose()
releaseObject(discovery)
}
}