none
Object reference not set to an instance of an object. RRS feed

  • Question

  • This error is logged in the event viewer:  Object reference not set to an instance of an object.

    The event indicates that the error occurs in orchestration shape Assign Vendor Code.  Assign Vendor Code has this expression:

    varCode = msgPurchaseOrder.Body.VendorCode;

    varVendorCode is a string.  msgPurchaseOrder is a multi-part message whose body part is type PurchaseOrder with a distinguished property of VendorCode.  Intellisense was happy to give me everything on the right side of the expression.  Running the orchestration in the debugger, the step previous to Assign Vendor Code receives msgPurchaseOrder.  The debugger shows that the message has a body and the body has the right content including the element reference by the distinguished field.  Replacing the right side with a constant results in everything running fine, so the error is related to the message.

    Friday, October 10, 2014 7:46 PM

Answers

  • If the problem persists, don't loose time too much on this.

    For your information, the distiguished is just a friendly use of the XPath. The pipeline only promotes the Promoted Elements or your schema, it doesn't do anything about the Distinguished fields.

    Are you sure your distinguished field is unique? This is a must

    I would advise you to use something like : 

    varCode = xpath(msgPurchaseOrder,"string(//VendorCode)")

    Regards,


    Reporting Solution for BizTalk | follow-us on twitter

    • Marked as answer by Jay Meerdink Monday, October 20, 2014 3:32 PM
    Monday, October 13, 2014 4:13 PM

All replies

  • Do you mean the Orchestration Debugger or Visual Studio?

    In Visual Studio, you should be able to see right away what piece is null, then backtrack.

    Friday, October 10, 2014 8:18 PM
    Moderator
  • The orchestration debugger.  Do you have a good reference to setup VS debugging of orchestrations?
    Friday, October 10, 2014 8:19 PM
  • Just attach to BTSNTSvc.exe and it should break on the exception if you've set that option.
    Friday, October 10, 2014 9:33 PM
    Moderator
  • Hi,

    Your issue looks similar to the one mentioned in the post. See if this helps.

    Rachit

    Please mark the post answered your question as answer, and mark other helpful posts as helpful, it'll help other users who are visiting your thread for the similar problem

    Saturday, October 11, 2014 3:47 AM
    Moderator
  • I marked the schema for Qualified Element FormDefault, on both the schema and the property schema (one at a time), and got the same results.  Thanks though.
    Saturday, October 11, 2014 5:42 PM
  • What is the order of operations here.  Attach to BNTSVC, then invoke the orchestration, and when it hits the breakpoint I set in the orch debugger it should stop in VS?  Sorry - I'm unclear on this.
    Saturday, October 11, 2014 5:44 PM
  • Is it possible that I'm never getting to a point where the distinguished field is written to the context?  The message flow is:

    Msg1 leaves the orchestration via a Solicit-Response port (to SQL).

    Msg2 comes back as the response, goes through the receive pipeline, has an inward map applied converting it to Msg3 that has the distinguished field.  Msg3 is returned to the orchestration, presumably never having been through a pipeline.

    Is the distinguished field written to the context in a pipeline?  If so, does Msg3 ever hit a pipeline?

    Monday, October 13, 2014 2:46 PM
  • I've tried to attach the VS debugger to BTSNTSvc but can't get anything meaningful out of the session.  Is there something that needs to be done in the project?
    Monday, October 13, 2014 2:47 PM
  • Yes, attach to BTSNTSvc.exe, then run the Orchestration.  It should break in the C# file generated from the Orchestration.

    This is just regular .Net debugging, other than the generated .cs file, there's nothing really BizTalk specific about it.

    The project must be compiled in Debug mode and CLR Exceptions must be set to Thrown in the Debug/Exceptions dialog.

    Monday, October 13, 2014 3:18 PM
    Moderator
  • There are no .cs files corresponding to the .odx files.

    I checked properties on the project, and I can't find anything about CLR Exceptions in a Debug / Exceptions dialog.

    Monday, October 13, 2014 3:37 PM
  • Jay,

    In order for you to generate cs file for odx you will gonna have to set a DWORD in registry at

    HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\{VS Version}

    Add DWORD "GenerateCSFiles" and set its value to 1.

    But one question regarding your issue. What pipeline are you using? Is it Passthrough ? If it is can you try using XmlReceive ?

    Properties get promoted or written into context when they go through pipeline.


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful.

    Monday, October 13, 2014 3:45 PM
  • If the problem persists, don't loose time too much on this.

    For your information, the distiguished is just a friendly use of the XPath. The pipeline only promotes the Promoted Elements or your schema, it doesn't do anything about the Distinguished fields.

    Are you sure your distinguished field is unique? This is a must

    I would advise you to use something like : 

    varCode = xpath(msgPurchaseOrder,"string(//VendorCode)")

    Regards,


    Reporting Solution for BizTalk | follow-us on twitter

    • Marked as answer by Jay Meerdink Monday, October 20, 2014 3:32 PM
    Monday, October 13, 2014 4:13 PM
  • I've made the registry entry, closed VS, reopened, rebuilt, no CS files for ODX.

    The pipeline I'm using is XMLReceive.

    Monday, October 13, 2014 9:12 PM
  • The xpath method worked.  It's irksome that I can't predict the behavior of the distinguished property though.

    Thanks for your help!

    Monday, October 13, 2014 9:13 PM
  • You don't need to locate the .cs file, it's there and Visual Studio will open it automatically.  No registry changes or anything, assuming you're using BizTalk Server 2009 or later.

    Hmm....weird...if the Exceptions dialog doesn't have an entry for Common Language Runtime (CLR) Exceptions, then there's something really wrong with Visual Studio.

    Monday, October 13, 2014 10:06 PM
    Moderator
  • If the Distinguished Field is not guaranteed to exist, then you have to test via xpath().  That's the most practical solution.
    Monday, October 13, 2014 10:06 PM
    Moderator
  • I'm sure I'm just looking for it in the wrong place.  Is it in properties on the project?
    Wednesday, October 15, 2014 2:23 PM
  • Jay,

    .CS is a hidden file in Visual Studio on project you have to click show all in order for you to see cs file.

    Can you please share the schema you have for this message?


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful.


    • Edited by SAAkhlaq Wednesday, October 15, 2014 2:39 PM edit
    Wednesday, October 15, 2014 2:31 PM
  • Right - I got that.  Show hidden files still doesn't show .cs files named for my .odx files.
    Wednesday, October 15, 2014 2:40 PM
  • Which BT version you are using?

    Also, Can you please share the schema you have for this message?


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful.

    Wednesday, October 15, 2014 2:45 PM
  • Don't worry about the .cs file.  Visual Studio will handle all that.

    The Exceptions dialog is usually found by Debug/Exceptions on the menu but it can change depending on what profile you choose when starting VS for the first time.  General and C# are different here, I just don't remember how.

    It has to be there somewhere and there has to be an entry for Common Language Runtime Exceptions.

    Wednesday, October 15, 2014 2:45 PM
    Moderator
  • BT2013

    <?xml version="1.0" encoding="utf-16"?>
    <xs:schema xmlns:type="http://Canon.Schema.Types/2014/10/2" xmlns="http://Canon.Schema.PurchaseOrder/2014/10/2" xmlns:poprops="https://Canon.Schema.PropertiesPurchaseOrder" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://Canon.Schema.PurchaseOrder/2014/10/2" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:import schemaLocation=".\Types.xsd" namespace="http://Canon.Schema.Types/2014/10/2" />
      <xs:annotation>
        <xs:appinfo>
          <b:imports>
            <b:namespace prefix="poprops" uri="https://Canon.Schema.PropertiesPurchaseOrder" location=".\PropertiesPurchaseOrder.xsd" />
          </b:imports>
          <b:references>
            <b:reference targetNamespace="http://Canon.Schema.Types/2014/10/2" />
          </b:references>
        </xs:appinfo>
      </xs:annotation>
      <xs:element name="PurchaseOrder">
        <xs:annotation>
          <xs:appinfo>
            <b:properties>
              <b:property name="poprops:POId" xpath="/*[local-name()='PurchaseOrder' and namespace-uri()='http://Canon.Schema.PurchaseOrder/2014/10/2']/*[local-name()='POId' and namespace-uri()='http://Canon.Schema.PurchaseOrder/2014/10/2']" />
              <b:property distinguished="true" xpath="/*[local-name()='PurchaseOrder' and namespace-uri()='http://Canon.Schema.PurchaseOrder/2014/10/2']/*[local-name()='VendorCode' and namespace-uri()='http://Canon.Schema.PurchaseOrder/2014/10/2']" />
            </b:properties>
          </xs:appinfo>
        </xs:annotation>
        <xs:complexType>
          <xs:sequence>
            <xs:element name="POId" type="xs:string" />
            <xs:element minOccurs="0" name="VendorCode" type="xs:string" />
            <xs:element minOccurs="0" name="EnteredDate" type="xs:string" />
            <xs:element minOccurs="0" name="ExpectedDueDate" type="xs:string" />
            <xs:element minOccurs="0" name="Contact" type="xs:string" />
            <xs:element minOccurs="0" name="TotalAmount" type="xs:float" />
            <xs:element minOccurs="0" name="Note" type="xs:string" />
            <xs:element minOccurs="0" name="CustomerPO" type="xs:string" />
            <xs:element minOccurs="0" name="Carrier" type="xs:string" />
            <xs:element minOccurs="0" name="FreightService" type="xs:string" />
            <xs:element minOccurs="0" name="FOB" type="xs:string" />
            <xs:element minOccurs="0" name="Terms" type="xs:string" />
            <xs:element name="ShipToAddress">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="AddressLine1" type="xs:string" />
                  <xs:element name="AddressLine2" type="xs:string" />
                  <xs:element name="AddressLine3" type="xs:string" />
                  <xs:element name="AddressLine4" type="xs:string" />
                  <xs:element name="City" type="xs:string" />
                  <xs:element name="State" type="xs:string" />
                  <xs:element name="PostalCode" type="xs:string" />
                  <xs:element name="Country" type="xs:string" />
                </xs:sequence>
              </xs:complexType>
            </xs:element>
            <xs:element name="VendorAddress">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="AddressLine1" type="xs:string" />
                  <xs:element name="AddressLine2" type="xs:string" />
                  <xs:element name="AddressLine3" type="xs:string" />
                  <xs:element name="AddressLine4" type="xs:string" />
                  <xs:element name="AddressLine5" type="xs:string" />
                  <xs:element name="AddressLine6" type="xs:string" />
                </xs:sequence>
              </xs:complexType>
            </xs:element>
            <xs:element minOccurs="0" name="Lines">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="LineNumber" type="xs:int" />
                  <xs:element name="ManufacturerPartNumber" type="xs:string" />
                  <xs:element name="VendorPartNumber" type="xs:string" />
                  <xs:element name="Quantity" type="xs:float" />
                  <xs:element name="Description" type="xs:string" />
                  <xs:element name="Cost" type="xs:float" />
                  <xs:element name="Note" type="xs:string" />
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>


    • Edited by Jay Meerdink Wednesday, October 15, 2014 6:26 PM
    Wednesday, October 15, 2014 2:52 PM
  • OK - Debug | Exceptions let me set CLR Exceptions to thrown.  I've attached to all 4 running instances of BTSNTSVC.  Set breakpoints in my orchestration.  Invoked it.  Saw it become a running process In Breakpoint (Active).  That's the point where I'd normally open in the orch debugger and attach, but VS isn't responding in any way.
    Wednesday, October 15, 2014 3:11 PM
  • No, don't set any Breakpoints in BT Admin, those are totally different Breakpoints.
    Wednesday, October 15, 2014 3:43 PM
    Moderator
  • What activates the VS debugger?
    Wednesday, October 15, 2014 3:45 PM
  • Attaching, then when any exception is Thrown, VS will break in it's debugger.  It will load the corresponding .cs file and put the cursor on the offending line, just like any other .Net program.
    Wednesday, October 15, 2014 3:51 PM
    Moderator
  • debugger is only option here.

    It is happened when right side part(msgPurchaseOrder.Body.VendorCode) is null. Null data trying to assign to variable.

    Are you using this code in Message assignment shape? then

    I suggest, this line of code(varCode = msgPurchaseOrder.Body.VendorCode;) put in expression shape after Receive shape in orchestration.

    Regards

    Suman



    Wednesday, October 15, 2014 4:10 PM
  • Right.  I put the error reference to the distinguished field back in the expression, attached to BTSNTSVC, ran the orchestration.  I saw a lot of stuff loaded in the debug output window, ending in 

    'BTSNTSvc64.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Management\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Management.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'BTSNTSvc64.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files (x86)\Microsoft BizTalk Server 2013 R2\Microsoft.BizTalk.EPMTransform.dll'. Cannot find or open the PDB file.
    'BTSNTSvc64.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.SqlXml\v4.0_4.0.0.0__b77a5c561934e089\System.Data.SqlXml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'BTSNTSvc64.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'System.Xml.Xsl.CompiledQuery.1'. 
    'BTSNTSvc64.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Canon\v4.0_1.0.0.0__3f49407b0759e798\Canon.dll'. Cannot find or open the PDB file.
    'BTSNTSvc64.exe' (CLR v4.0.30319: __XDomain_3.0.1.0_0): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Canon\v4.0_1.0.0.0__3f49407b0759e798\Canon.dll'. Cannot find or open the PDB file.
    'BTSNTSvc64.exe' (CLR v4.0.30319: __XDomain_3.0.1.0_0): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.BizTalk.XPathReader\3.0.1.0__31bf3856ad364e35\Microsoft.BizTalk.XPathReader.dll'. Cannot find or open the PDB file.

    It appears that the debugger can't find the appropriate PDB files.

    Canon.dll is referenced from a different project.  That's the project where my canonical schema are defined.

    How do I register the PDB files so that the debugger can find them?

     
    Wednesday, October 15, 2014 5:05 PM
  • Jay,

    Can you please share the sample as well that you using to test the service?


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful.

    Wednesday, October 15, 2014 5:27 PM
  • <?xml version="1.0"?>
    <dest:PurchaseOrder xmlns:row="http://schemas.microsoft.com/Sql/2008/05/ProceduresResultSets/dbo/GetPOs" xmlns:rt="http://schemas.microsoft.com/Sql/2008/05/TypedProcedures/dbo" xmlns:dest="http://Canon.Schema.PurchaseOrder/2014/10/2">
    <POId>2384374</POId>
    <VendorCode>SYNX01</VendorCode>
    <EnteredDate>2014-07-16T10:55:05.42Z</EnteredDate>
    <ExpectedDueDate>2014-07-16T10:54:42.71Z</ExpectedDueDate>
    <Contact>JRL4333</Contact>
    <TotalAmount>1932.53000000</TotalAmount>
    <Note/>
    <CustomerPO>test</CustomerPO>
    <Carrier>FED EX GROUND</Carrier>
    <FreightService>FED EX GROUND</FreightService>
    <FOB>DEST</FOB>
    <Terms>CAS</Terms>
    -<ShipToAddress>
    <AddressLine1>1 FORTRAN DRIVE</AddressLine1>
    <AddressLine2>ATTN: INFORMATION SERVICES DEPT</AddressLine2>
    <AddressLine3/>
    <AddressLine4/>
    <City>SHIRECASTER</City>
    <State>NY</State>
    <PostalCode>22222</PostalCode>
    <Country>US</Country>
    </ShipToAddress>
    -<VendorAddress>
    <AddressLine1>SYNNEX INFORMATION TECH</AddressLine1>
    <AddressLine2>39 RIDGE DRIVE</AddressLine2>
    <AddressLine3/>
    <AddressLine4>GREEN VILLAGE, NC 22222</AddressLine4>
    <AddressLine5>USA</AddressLine5>
    <AddressLine6/>
    </VendorAddress>
    <Lines>
    <LineNumber>1</LineNumber>
    <ManufacturerPartNumber>CD644A#BGJ</ManufacturerPartNumber>
    <VendorPartNumber>3197661</VendorPartNumber>
    <Quantity>1</Quantity>
    <Description>HP COLOR LASERJET ENTERPRISE M575DN MFP</Description>
    <Cost>1932.53000000</Cost>
    <Note>90821942 $1,773.55 + .75%=1786.85PO#2383515 >07/15/14 - Closed By Auto PO - Recvd=1.0<</Note>
    </Lines>
    </dest:PurchaseOrder>
    • Edited by Jay Meerdink Wednesday, October 15, 2014 6:25 PM
    Wednesday, October 15, 2014 5:33 PM
  • Jay,

    The sample you are using is not valid according to the schema you have shared.

    Can you please confirm if it is the right schema and message? If the schema is right then most probably it will work once you use valid sample input.

    Can you please try following message?

    <PurchaseOrder xmlns:row="http://schemas.microsoft.com/Sql/2008/05/ProceduresResultSets/dbo/GetPOs" xmlns:rt="http://schemas.microsoft.com/Sql/2008/05/TypedProcedures/dbo" xmlns="http://Canon.Schema.PurchaseOrder/2014/10/2">
      <POId>2384374</POId>
      <VendorCode>SYNX01</VendorCode>
      <EnteredDate>2014-07-16T10:55:05.42Z</EnteredDate>
      <ExpectedDueDate>2014-07-16T10:54:42.71Z</ExpectedDueDate>
      <Contact>JRL4333</Contact>
      <TotalAmt>1932.53000000</TotalAmt>
      <Note/>
      <CustomerPO>test</CustomerPO>
      <Carrier>FED EX GROUND</Carrier>
      <FreightService>FED EX GROUND</FreightService>
      <FOB>DEST</FOB>
      <Terms>CAS</Terms>
      <ShipToAddress>
        <AddressLine1>1 FORTRAN DRIVE</AddressLine1>
        <AddressLine2>ATTN: INFORMATION SERVICES DEPT</AddressLine2>
        <AddressLine3/>
        <AddressLine4/>
        <City>SHIRECASTER</City>
        <State>NY</State>
        <PostalCode>22222</PostalCode>
        <Country>US</Country>
      </ShipToAddress>
      <VendorAddress>
        <AddressLine1>SYNNEX INFORMATION TECH</AddressLine1>
        <AddressLine2>39 RIDGE DRIVE</AddressLine2>
        <AddressLine3/>
        <AddressLine4>GREEN VILLAGE, NC 22222</AddressLine4>
        <AddressLine5>USA</AddressLine5>
        <AddressLine6/>
      </VendorAddress>
      <Lines>
        <LineNumber>1</LineNumber>
        <ManufacturerPartNumber>CD644A#BGJ</ManufacturerPartNumber>
        <VendorPartNumber>3197661</VendorPartNumber>
        <Quantity>1</Quantity>
        <Description>HP COLOR LASERJET ENTERPRISE M575DN MFP</Description>
        <Cost>1932.53000000</Cost>
        <Note>90821942 $1,773.55 + .75%=1786.85PO#2383515 >07/15/14 - Closed By Auto PO - Recvd=1.0</Note>
      </Lines>
    </PurchaseOrder>


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful.

    Wednesday, October 15, 2014 5:44 PM
  • I made one small change inline in the example (TotalAmt -> TotalAmount) and I reset ElementFormDefault to default, again inline in this thread.
    Wednesday, October 15, 2014 6:30 PM
  • So long as the Orchestration assembly is compiled in Debug mode, it should work, meaning break on error.
    • Proposed as answer by Ismailmgl Thursday, October 16, 2014 2:16 AM
    • Unproposed as answer by Ismailmgl Thursday, October 16, 2014 2:16 AM
    Wednesday, October 15, 2014 10:32 PM
    Moderator
  • Could you try fetching the field value using xpath ?

    varCode = xpath(msgPurchaseOrder.Body,"string(<xpath of vendor code>)")

    to verify if the mulitpart and distinguish filed has a prob?

    Thursday, October 16, 2014 2:31 AM
  • Xpath works.
    Thursday, October 16, 2014 12:41 PM