c# - ProcessIdToSessionId returns wrong session ID -


i have c# service web socket server. when web socket connection received process id of connecting application (chrome) socket , session id of process. getting process id , session id done in c++ dll loaded c# service.

looking @ processes tab in task manager see entry chrome.exe pid of 5640 , session id of 45.

in c++ dll using getextendedtcptable() find process id port. seems work fine retrieve correct process id (in example pid 5640). when use process id in processidtosessionid() session id returned 44!

why processidtosessionid() return wrong session id?

os windows 7 32bit.

just discovered problem! used wrapper function call processidtosessionid(). function written application started in session optimised session id once , saved internally. idea behind unnecessary re-query session id current process session id never change. when function called subsequently did not call processidtosessionid() again returned stored value.

of course re-using function in service gets called different sessions received correct session id on first call subsequent calls received wrong session id. changing wrapper function force re-querying session id fixed problem.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -