How to debug static (custom) service type

  • 13 July 2009
  • 3 replies
  • 0 views

Badge +6

Hi ,


I have developed static (custom) service type that retrieves data from multiple tables in the database. I have tested the data retrieval code and Sql query in the console application. Its working perfect, But when I test the Service type with Smart object tool , Its throwing an exception. I am not aware of the debugging the service type to find out the error source.


 


Could you please let me know the steps to debug the static service type code.


Appreciate your help.


Thanks


Jayaprakash N M


 


3 replies

Badge +11

Jayaprakash,


A static service is a .NET assembly that is loaded by a host application.  The debugging approach is the same as it is for any other .NET assembly of this type. 



  1. Load your project
  2. The project must be exactly the same version as what is deployed
  3. Set your breakpoints
  4. In VS, go to Debug | Attach to Process
  5. Select K2HostServer.exe and attach
  6. Exercise a SmartObject that uses your service and your breakpoint should be hit

If you have VS on the same machine as the K2HostServer, this should be pretty easy.  If you are debugging on a remote machine, you will have to follow the instructions to setup and enable remote debugging on that machine.


ServiceObjects aren't loaded into the process until they are needed, therefore, you may see a question mark on the breakpoint until the assembly is loaded.  If you make changes to your ServiceObject, you will have to stop the host server, copy your DLL, and restart the host server.  You need to do this because once .NET loads an assembly into an app domain, it is never unloaded unitl the app domain is unloaded.  If you are debugging on the same machine running K2HostServer, you can this tip to automate the stop/copy/restart sequence.


http://www.k2underground.com/blogs/blacktop/archive/2009/04/01/tip-testing-custom-smartobject-services.aspx


 

Badge +9

David makes some excellent points here.


FYI, in case you (or others) aren't familar with how to setup remote debugging with Visual Studio, there is soem guidance here: http://support.microsoft.com/kb/910448


 

Badge +6

David and Bob, Thanks for your info.


I am facing couple of issues in development of Static Service as below


1) The service type refers (cache) the old assembly and it takes more than 15 min to clear the old assembly cache, even after replacing new assembly    ( DLL)


2) I have to do  "refresh Service Instance" many times ( ~ 20 times)  to update the schema of the service instace.


3) I could not find any info regarding deployment ( Moving Test to Production)


 Could please let me know the workarounds , if there are any  

Reply