Question Managed Debugging Assistant 'DisconnectedContext'

cbreemer

Well-known member
Joined
Dec 1, 2021
Messages
184
Programming Experience
10+
Oh damn... my program to copy files from my smartphone to PC was running happily so I went and had dinner. Coming back, expecting it to have finished, I found that just over halfway it had ran into this strange error, see image. I'm not using COM or threading in my code (but could be the MediaDevices interface does so). The option "Continue" does not help, the error comes straight back again. I just wanted to see if anyone had ever experienced this ?

break.jpg
 
If you are using async/await in your code (or the libraries you use), you can be using threading without knowing it. A lot of the .NET Framework are just wrappers around Win32 APIs that are COM based.
 
If you are using async/await in your code (or the libraries you use), you can be using threading without knowing it. A lot of the .NET Framework are just wrappers around Win32 APIs that are COM based.
Thanks. Yes I know, but I don't have any async code. Or maybe I do... by using the Process class. After copying an image from phone to PC, I add the EXIF tag DateTimeOriginal to the new file on the PC, by spawning the exiftool program, using this code:

Adding the EXIF tag:
string dateTimeOriginal = dateAuthored.ToString(Main.DTFORMAT_SORT);
string args = $"-overwrite_original -DateTimeOriginal=\"{dateTimeOriginal}\" {newPath}";
Process p = Process.Start(EXIFTOOL, args);
p.WaitForExit();

I guess this may introduce threading just like async/await. Then again I wait for it, so why should it be an issue ?
But behold, if I skip this code, the problem does not seem to occur. Hmmmm...
Of course I'd much rather add the tag with in-process code (running a program takes so much mode time) but I've not been able to find a package that can do this. Better have another look.
 
That should all be synchronous there.

If you look closely at your screenshot, the error happened on thread 604. The next time you get that error, look at the callstack to try to see if you see any method names that may suggest how you got there.
 
That should all be synchronous there.

If you look closely at your screenshot, the error happened on thread 604. The next time you get that error, look at the callstack to try to see if you see any method names that may suggest how you got there.
Yes I noticed that, but stupidly I did not think of checking the call stack. Whenever I see errors related to COM I tend to run away in distress 😲
 
Back
Top Bottom