none
Debug orchestration inside visual studio

    Question

  • Hi,

    How can I easily debug C# code inside orchestration – expression shape, message assign shape, whatever – inside visual studio??

    Without using helper class (class library)


    Sandro Pereira - http://sandroasp.spaces.live.com/blog/ http://www.devscope.net/WhatWeDo/Integration/tabid/107/Default.aspx
    Monday, September 7, 2009 2:22 PM
    Moderator

Answers

All replies

  • You can debug an orchestration inside HAT. Right click the orchestration and click debug orchestration then insert breakpoints on shapes. Then activate the orchestration by sending the message. Right click the orchestration and click debug. Then press CTRL+A to attach to the orchestration to the running instance. By pressing CTRL+G you can step forward and debug your orchestration.

    Inside VS Orchestrations cannot be debugged. If you have a helper class you have to debug it through a Windows Application or Console project.
    Abdul Rafay http://abdulrafaysbiztalk.wordpress.com/ Please mark this answer if it helps
    Monday, September 7, 2009 2:43 PM
  • I think Yossi is correct, you can place breakpoints within statements in expression shape or construct.

    As far as helper class debugging is concerned, you can put a break point on the helper class, attatch the Visual studio debugger to the appropritae BizTalk host instance and it will break when that statement (with break point) will be execute.

    Regards,

    Tariq Majeed 
    Monday, September 7, 2009 3:01 PM
  • Hi,

    Thank you for trying to help.

    Finally I discover how to do.
    Yes, it’s possible to debug inside visual studio C# code in expression shape without using helper class (class library), finally I discover how to do.

    In the past, when I debug a class library, for mistake I was able to generate a orchestration.odx.cs file, and for my surprise I was able to debug inside orchestration with visual studio but I don’t know how I was able to do this until now J

    So how can I do this?

    1.    Go to regedit;

    2.    Add a registry key named BizTalkProject at  [HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0]
    (if you are using BizTalk 2004 and Visual Studio .NET 2003 is HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\7.1)

    3.    Next, create a DWORD value named “GenerateCSFile” and set it to 1

    4.    Setting the Generate Debugging Information = True property by right-clicking on the project in Visual Studio and selecting Properties Configuration Properties Build will ensure that the C# files are created for debug builds in BizTalk 2006.

    5.    If you rebuild your project, you will see C# files in your project directory (Click show hidden files and you should see a file named <OrchestrationName>.odx..cs);

    My Post: http://sandroasp.spaces.live.com/blog/cns!98A008F39B7BBF8E!311.entry

    References: http://books.google.pt/books?id=iKklnd5bq_kC&pg=PA139&lpg=PA139&dq=%5BHKEY_CURRENT_USER%5CSoftware%5CMicrosoft%5CVisualStudio%5C8.0%5CBiztalkProject%5D&source=bl&ots=fgW4Afo8iQ&sig=KR3XAI3eOZ1qoZ6fc1v59qH7O9I&hl=pt-PT&ei=4iSlSr-eBqWhjAfR84mJCg&sa=X&oi=book_result&ct=result&resnum=5#v=onepage&q=&f=false

    And

    http://books.google.pt/books?id=Lbrnnq_j0VsC&pg=PA98&lpg=PA98&dq=%5BHKEY_CURRENT_USER%5CSoftware%5CMicrosoft%5CVisualStudio%5C8.0%5CBiztalkProject%5D&source=bl&ots=iBt5cuzTvp&sig=Zk9fZfePlfsvjBUaeT3qr7tPZbY&hl=pt-PT&ei=4iSlSr-eBqWhjAfR84mJCg&sa=X&oi=book_result&ct=result&resnum=1#v=onepage&q=&f=false


    Sandro Pereira - http://sandroasp.spaces.live.com/blog/ http://www.devscope.net/WhatWeDo/Integration/tabid/107/Default.aspx
    Monday, September 7, 2009 4:44 PM
    Moderator
  • Sandro,

    The C# file is generated against each orchestration after editing the registry value. But the orchestration behaviour is different than from this generated C# file. You cannot see the message body and the context properties with this C# file. There are a lot of other things that are different in the orchestration and the generated code. Of course if you have inline codes in expression editor they will be compiled as is with the file but it doesn't mean that "Debugging the orchestration" and the C# file are the same.

    Abdul Rafay http://abdulrafaysbiztalk.wordpress.com/ Please mark this answer if it helps
    Monday, September 7, 2009 4:51 PM
  • Hi Abdul,

    I do not disagree with you, however if we have some code inside orchestration, it’s very difficult to debug orchestration and see what’s real happened.

    We have to look for an exception, or see in HAT if some variable (for example) are with the expect value or not, with some lucky see Event Viewer for some additional information, but using HAT we cannot now what’s real appended inside shapes!

    Why we can easily debug maps, pipelines and components but not orchestration?

    With this “tip” we maybe can see what’s real happened with some code inside orchestration, and adding the two (HAT and visual studio debug) I think is easier to see what’s the problem.

     


    Sandro Pereira - http://sandroasp.spaces.live.com/blog/ http://www.devscope.net/WhatWeDo/Integration/tabid/107/Default.aspx
    Monday, September 7, 2009 5:06 PM
    Moderator
  • Just in case someone wants to get the BizTalk 2009 version of the orchestration c# file to attach to BTSNtsvc.exe the files are found under the “obj\Debug\BizTalk\XLang” folder under the BizTalk project folder after it's built in Debug mode.
    I helped Gerben find it and he posted it on his blog:
     http://www.businessprocessintegration.net/2009/09/how-to-debug-an-orchestration-in-biztalk-server-2009/

    Regards,
    Thiago Almeida - http://connectedthoughts.wordpress.com
    Friday, September 11, 2009 10:22 AM
    Answerer
  • Thanks Thiago for complete my response.

    I spend some time this morning to test this new “feature” and I read the Gerben post and here some additional information that I think is useful:

    Another difference is that if we have more than one orchestration, when we compile the solution, Visual Studio DON’T generate two CS files (File0.cs and File1.cs), he only generate one, and the two (or more) orchestrations code are inside the file: File0.cs

    Inside this file he creates different class according to the orchestration Typename property, sample:

    ·         sealed internal class BizTalk_Orchestration1 : Microsoft.BizTalk.XLANGs.BTXEngine.BTXService …

    ·         sealed internal class BizTalk_Orchestration2 : Microsoft.BizTalk.XLANGs.BTXEngine.BTXService

     

     


    Sandro Pereira - http://sandroasp.spaces.live.com/blog/ http://www.devscope.net/WhatWeDo/Integration/tabid/107/Default.aspx
    Friday, September 11, 2009 1:22 PM
    Moderator
  • Fair point Sandro and an interesting approach; I was clearly wrong when I said it was not possible; however - I do question the need! and I've posted some thoughts on this here
    Yossi Dahan http://www.sabratech.co.uk/blogs/yossidahan [To help others please mark replies as answers if you found them helpful]
    Friday, September 11, 2009 1:37 PM
    Moderator
  • I opened the File0.cs as a seperate file in VS 2008 Editior and attach to BTSNtsvc.exe.
    But while setting the breakpoing I'm getting the warnig message which says that 'The Breakpoing will not be currently hit. No symbols have been loaded for this document'.

    Thanks in advance.
    Wednesday, October 7, 2009 3:41 PM
  • Hi,

    See this thread: http://social.msdn.microsoft.com/forums/en-US/vbide/thread/557fdedb-268e-48a8-9944-29b2b4e0dec2/

    Click on the Menu item for Build then select Configuration Manager. Here you can set the configuration for each project in your solution. In order for the ide to debug your library, it needs to be able to find the debug symbols which are generated when you build with the debug flag turned on. This is easiest set by setting the configuration option to debug.

    As far as building a class library, you can do it any of a number of ways. Selecting the library, right clicking and selecting Build, or using the build menu option.


    Sandro Pereira - http://sandroasp.spaces.live.com/blog/ http://www.devscope.net/WhatWeDo/Integration/tabid/107/Default.aspx
    Wednesday, October 7, 2009 5:06 PM
    Moderator
  • Thanks Sandro for replying.
    The debugger worked for me without setting the symbol, on opening the file as a seperate file in VS 2008 (not as a project) and attaching the debug process to BTSNtsvc.exe.

    Thanks again for the reply.
    Thursday, October 8, 2009 4:18 PM