Debugging server event code

  • 30 January 2008
  • 8 replies
  • 2 views

Badge +1

Hello,

How can i debug a server event? I tried to run the  the process from the visual studio with a breakpoint set in code.

after trying to start the project, i only get : project of an output type class library cannot be started directly and a status Deploy succeeded.

Is there a way to debug the process? I tried to attach to the K2HostServer.exe process, but the breakpoint shows an exclamation mark that it will not be hit hence symbols were not loaded for the project..

 

Thank you 


8 replies

Badge +11

You're on the right track attaching to the K2HostServer.exe.  When you attach the debugger, choose to debug managed code only.  The exclamation points will go away when the host server loads your assembly and your breakpoint will be hit when it is executed.


The host server takes care of versioning your process, so make sure the process version you are debugging matches your source code. 

Badge +1

Thank you, it worked as you've said. But there is an issue when i try to access either K2.ProcessInstance.XmlFields or K2.ProcessInstance.DataFields from the Watch window of the Visual Studio.

it throws error:   K2.ProcessInstance.XmlFields    Cannot obtain fields or call methods on the instance of type 'SourceCode.KO.ProcessInstance' because it is a proxy to a remote object.    SourceCode.KO.XmlFields

On the other side when i save K2.ProcessInstance.XmlFields["Test"] (an existing item) to the file, there's its content..

 is this a common behavior?

 

Badge +7
Hi DavidL,

I've done as you've suggested, however I still get this message when hovering over my breakpoint:

no symbols have been loaded for this document

any ideas,

Martin

Edit: when you get to the point in your workflow where you placed the breakpoint... all is well :-)
Badge +8

Just to share my own experience about this: I sometimes encounter the same problem, sometimes not, but I don't know the exact cause. I suspect it's a kind of bad sync between Visual Studio and the process it's attached to.


For the exact same process, and with the exact same breakpoints, I was able to read the actual value of the fields in more than 50% of my attempts.

Badge +7
I did a short guide on how to do this here, http://blog.mgallen.com/?p=153

Martin
Badge +6

Something else to add to this discussion is that you can also do remote debugging if you do not have VS on your server. For this you must make sure that the Visual Studio 2005 Remote Debugger service is started on the remote machine and also that you are part of Debuggers Users group on that machine.


Also pay attention to the steps above for selecting only managed code when doing this for I have not figured out how to do remote with WF code..


Also keep in mind that when you do hit a breakpoint, the whole K2 service will come to a standstill so this might disrupt other developers working on the same machine.


Cheers,

Badge +7
thanks Gehard - this makes it more complete as a guide...

Martin
Badge +1

@kornyi


it throws error:   K2.ProcessInstance.XmlFields    Cannot obtain fields or call methods on the instance of type 'SourceCode.KO.ProcessInstance' because it is a proxy to a remote object.    SourceCode.KO.XmlFields


Did you find a resolution to this? I am having the same issue.

Reply