BizTalk BizTalk2006.Application.Exists Object reference not set to an instance of an object error

Nov 25, 2009 at 11:05 AM

Hi

I would be grateful for some help to resolve the problem described below - thanks in advance.

I am using SDC Tasks - Release 2.1.3155.0 and I get an error when I call some of the BizTalk tasks such as:
BizTalk2006.Application.Exists, Microsoft.Sdc.Tasks.BizTalk2006.Application.Delete and BizTalk2006.Application.AddReferences.

I think I have installed the sdc tasks correctly as some of the tasks work correctly such as Microsoft.Sdc.Tasks.BizTalk2006.Application.Create.

BizTalk2006.Application.Exists, Microsoft.Sdc.Tasks.BizTalk2006.Application.Delete and BizTalk2006.Application.AddReferences all give a similar error.

The stack trace resulting from BizTalk2006.Application.Exists is:

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Executing script

C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\Microsoft.Sdc.Tasks.Test>SET VS80IDE=C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\
ECHO is on.

C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\Microsoft.Sdc.Tasks.Test>"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\msbuild.exe" Microsoft.Sdc.Tasks.Test.proj /Target:AppExists
Microsoft (R) Build Engine Version 2.0.50727.3053
[Microsoft .NET Framework, Version 2.0.50727.3082]
Copyright (C) Microsoft Corporation 2005. All rights reserved.

Build started 25/11/2009 11:53:28.
__________________________________________________
Project "C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\Microsoft.Sdc.Tasks.Test\Microsoft.Sdc.Tasks.Test.proj" (AppExists target(s)):

Target AppExists:
    C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\Microsoft.Sdc.Tasks.Test\Microsoft.Sdc.Tasks.Test.proj(28,3): error : A task error has occured.
    C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\Microsoft.Sdc.Tasks.Test\Microsoft.Sdc.Tasks.Test.proj(28,3): error : Message     = Object reference not set to an instance of an object.
    C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\Microsoft.Sdc.Tasks.Test\Microsoft.Sdc.Tasks.Test.proj(28,3): error : DoesExist   = False
    C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\Microsoft.Sdc.Tasks.Test\Microsoft.Sdc.Tasks.Test.proj(28,3): error : Application = Tpf.Service
    C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\Microsoft.Sdc.Tasks.Test\Microsoft.Sdc.Tasks.Test.proj(28,3): error : Database    = BizTalkMgmtDB
    C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\Microsoft.Sdc.Tasks.Test\Microsoft.Sdc.Tasks.Test.proj(28,3): error : Server      = ZZDUKJ3DVT1J
    C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\Microsoft.Sdc.Tasks.Test\Microsoft.Sdc.Tasks.Test.proj(28,3): error :
    C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\Microsoft.Sdc.Tasks.Test\Microsoft.Sdc.Tasks.Test.proj(28,3): error :    at Microsoft.Sdc.Tasks.BizTalk2004.BizTalk2004TaskBase.GetBtsCatalogExplorer(String server, String database) in c:\projects\codeplex\sdctasks\Solutions\Main\Tasks.BizTalk\2004\BizTalk2004TaskBase.cs:line 100
    C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\Microsoft.Sdc.Tasks.Test\Microsoft.Sdc.Tasks.Test.proj(28,3): error :    at Microsoft.Sdc.Tasks.BizTalk2006.Application.Exists.InternalExecute() in c:\projects\codeplex\sdctasks\Solutions\Main\Tasks.BizTalk\2006\Application\Exists.cs:line 54
    C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\Microsoft.Sdc.Tasks.Test\Microsoft.Sdc.Tasks.Test.proj(28,3): error :    at Microsoft.Sdc.Tasks.TaskBase.Execute() in c:\projects\codeplex\sdctasks\Solutions\Main\Tasks\TaskBase.cs:line 66
Done building target "AppExists" in project "Microsoft.Sdc.Tasks.Test.proj" -- FAILED.

Done building project "Microsoft.Sdc.Tasks.Test.proj" -- FAILED.

Build FAILED.
C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\Microsoft.Sdc.Tasks.Test\Microsoft.Sdc.Tasks.Test.proj(28,3): error : A task error has occured.
C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\Microsoft.Sdc.Tasks.Test\Microsoft.Sdc.Tasks.Test.proj(28,3): error : Message     = Object reference not set to an instance of an object.
C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\Microsoft.Sdc.Tasks.Test\Microsoft.Sdc.Tasks.Test.proj(28,3): error : DoesExist   = False
C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\Microsoft.Sdc.Tasks.Test\Microsoft.Sdc.Tasks.Test.proj(28,3): error : Application = Tpf.Service
C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\Microsoft.Sdc.Tasks.Test\Microsoft.Sdc.Tasks.Test.proj(28,3): error : Database    = BizTalkMgmtDB
C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\Microsoft.Sdc.Tasks.Test\Microsoft.Sdc.Tasks.Test.proj(28,3): error : Server      = ZZDUKJ3DVT1J
C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\Microsoft.Sdc.Tasks.Test\Microsoft.Sdc.Tasks.Test.proj(28,3): error :
C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\Microsoft.Sdc.Tasks.Test\Microsoft.Sdc.Tasks.Test.proj(28,3): error :    at Microsoft.Sdc.Tasks.BizTalk2004.BizTalk2004TaskBase.GetBtsCatalogExplorer(String server, String database) in c:\projects\codeplex\sdctasks\Solutions\Main\Tasks.BizTalk\2004\BizTalk2004TaskBase.cs:line 100
C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\Microsoft.Sdc.Tasks.Test\Microsoft.Sdc.Tasks.Test.proj(28,3): error :    at Microsoft.Sdc.Tasks.BizTalk2006.Application.Exists.InternalExecute() in c:\projects\codeplex\sdctasks\Solutions\Main\Tasks.BizTalk\2006\Application\Exists.cs:line 54
C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\Microsoft.Sdc.Tasks.Test\Microsoft.Sdc.Tasks.Test.proj(28,3): error :    at Microsoft.Sdc.Tasks.TaskBase.Execute() in c:\projects\codeplex\sdctasks\Solutions\Main\Tasks\TaskBase.cs:line 66
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.21

Developer
Nov 25, 2009 at 11:39 AM

Looks like the tasks are installed ok. It's a bit odd. Can you post the xml you are using to call the tasks. Do you know if the MSBuild Extension Pack tasks also error for you?

Mike

Nov 25, 2009 at 12:32 PM

Mike

Thanks for taking a look.

I dont know if the MSBuild Extension Pack tasks also error as I have not tried them. I will try them and see.

This is the xml used to call the tasks.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Import Project="C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\BuildTasks\Microsoft.Sdc.Tasks\Microsoft.Sdc.Common.tasks"/>
    
    <PropertyGroup>
        <AppExists>False</AppExists>
        <DoesExist>False</DoesExist>
    </PropertyGroup>    
    
    <!-- BT Applications -->
    <PropertyGroup>
        <TpfCommonComponents>Tpf.Common.Components</TpfCommonComponents>
        <TpfService>Tpf.Service</TpfService>
  </PropertyGroup>
            
    <PropertyGroup>
        <BTServerName>ZZDUKJ3DVT1J</BTServerName>
        <BTServerDatabase>BizTalkMgmtDB</BTServerDatabase>
  </PropertyGroup>
            

    
    <Target Name="Default">
        <CleanFolder Path="c:\MyCleanFolder" Force="True"/>
    </Target>
    
    <Target Name="AppExists" >
        <BizTalk2006.Application.Exists Application="Tpf.Service" Server="ZZDUKJ3DVT1J" Database="BizTalkMgmtDB" >
               <Output TaskParameter="DoesExist" PropertyName="AppExists" />
        </BizTalk2006.Application.Exists>
        <Message text="App Exists:" />
    </Target>    
    
      <Target Name="CreateBTSApplication">
        <Microsoft.Sdc.Tasks.BizTalk2006.Application.Create Application="MyApplication" />
      </Target>
      
      <Target Name="DeleteBTSApplication">
        <Microsoft.Sdc.Tasks.BizTalk2006.Application.Delete Application="MyApplication" Server="$(BTServerName)" Database="$(BTServerDatabase)"/>
      </Target>
      
      

  <ItemGroup>
    <BTRef Include="$(TpfCommonComponents)"></BTRef>
  </ItemGroup>

  <Target Name="ApplicationReferences">
        <BizTalk2006.Application.AddReferences
            Application="$(TpfService)"
            Server="$(BTServerName)"
            Database="$(BTServerDatabase)"
            ReferenceApplications="$(TpfCommonComponents)" />
        <!--Message Text="Set References: @(BTRef)"></Message-->
  </Target>      
    
</Project>

Nov 25, 2009 at 1:39 PM

Hi Mike

I do have a problem when running the MSBuild Extension Pack tasks.

I have installed the MSBuild Extension Pack tasks v3.5.4.0

However I do not have the specified prerequisit version of the Microsoft .NET Framework. I am running Version 2.0.50727.3082.on XP Service pack 3.

This deployment is for a BizTalk 2006 R2 deployment.

I get the error below when running the example BTApplication.proj.

The script and resulting error are below.

 

-----------------------------------------------------------------------------------------

Executing script

C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\MSBuildExtensionPack.Test>SET VS80IDE=C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\
ECHO is on.

C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\MSBuildExtensionPack.Test>"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\msbuild.exe" BTApplication.proj  
Microsoft (R) Build Engine Version 2.0.50727.3053
[Microsoft .NET Framework, Version 2.0.50727.3082]
Copyright (C) Microsoft Corporation 2005. All rights reserved.

Build started 25/11/2009 14:27:52.
__________________________________________________
Project "C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\MSBuildExtensionPack.Test\BTApplication.proj" (default targets):

Target Default:
  C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\MSBuildExtensionPack.Test\BTApplication.proj(11,13): error MSB4067: The element <Apps> beneath element <ItemGroup> is unrecognized.
Done building target "Default" in project "BTApplication.proj" -- FAILED.

Done building project "BTApplication.proj" -- FAILED.

Build FAILED.
C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\MSBuildExtensionPack.Test\BTApplication.proj(11,13): error MSB4067: The element <Apps> beneath element <ItemGroup> is unrecognized.
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.01

------------------------------------------------------------------------------------------------------------------------------

<Project ToolsVersion="3.5" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <TPath>$(MSBuildProjectDirectory)\..\MSBuild.ExtensionPack.tasks</TPath>
        <TPath Condition="Exists('$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks')">$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks</TPath>
    </PropertyGroup>
    <!--Import Project="$(TPath)"/-->
    <Import Project="C:\ccviews\CorneyG_TC_DEV_REL_1\TCSYS01\TC\Source\BuildBTApps\BuildTasks\MSBuild.ExtensionPack\MSBuild.ExtensionPack.tasks"/>
    
    <Target Name="Default">
        <ItemGroup>
            <Apps Include="An Application"/>
            <NewApps Include="NewExtensionPackApp">
                <!--<Default>true</Default>-->
                <Description>New ExtensionPack App</Description>
            </NewApps>
            <Reference Include="Another Application"/>
        </ItemGroup>
        <!-- Get a list of BizTalk Applications -->
        <MSBuild.ExtensionPack.BizTalk.BizTalkApplication TaskAction="Get">
            <Output TaskParameter="Applications" ItemName="ApplicationList"/>
        </MSBuild.ExtensionPack.BizTalk.BizTalkApplication>
        <Message Text="%(ApplicationList.Identity)"/>
        <!-- Add a Reference -->
        <MSBuild.ExtensionPack.BizTalk.BizTalkApplication TaskAction="AddReference" Application="An Application" References="@(Reference)"/>
        <!-- Remove a Reference -->
        <MSBuild.ExtensionPack.BizTalk.BizTalkApplication TaskAction="RemoveReference" Application="An Application" References="@(Reference)"/>
        <!-- Check if the Applications in the Apps collection exist -->
        <MSBuild.ExtensionPack.BizTalk.BizTalkApplication TaskAction="CheckExists" Applications="@(Apps)"/>
        <!-- Execute a StartAll on the Apps Application collection -->
        <MSBuild.ExtensionPack.BizTalk.BizTalkApplication TaskAction="StartAll" Applications="@(Apps)"/>
        <!-- Execute a StopAll on the Apps Application collection -->
        <MSBuild.ExtensionPack.BizTalk.BizTalkApplication TaskAction="StopAll" Applications="@(Apps)"/>
        <!-- Force the creation of the Applications in the NewApps collection -->
        <MSBuild.ExtensionPack.BizTalk.BizTalkApplication TaskAction="Create" Applications="@(NewApps)" Force="true"/>
        <!-- Delete the Applications in the NewApps collection-->
        <MSBuild.ExtensionPack.BizTalk.BizTalkApplication TaskAction="Delete" Applications="@(NewApps)"/>
    </Target>
    
</Project>

Nov 25, 2009 at 1:58 PM

Hi Mike

My problem with MSBuild Extension Pack is becuase I am not running Microsoft.NET\Framework\v3.5\msbuild.exe.

My apologies. I will try performing the BizTalk deployment tasks I need using the MSBuild Extension Pack.

Many thanks for your help.

Geoff

Developer
Nov 25, 2009 at 2:08 PM

Yes you will need 3.5.

I can repro your issue on the latest public build , but not on the latest code. I think one of the checkins I have done post the latest release has addressed the issue you are having. If you can use the extension pack, get the latest SDC code and compile it yourself. It should then work.

 

Mike

Nov 26, 2009 at 12:07 PM

Hi Mike

Using Microsoft.NET\Framework\v3.5 and that works in that I can get the the example BTApplication.proj working fine.

But I am not sure how I can use task MSBuild.ExtensionPack.BizTalk.BizTalkApplication TaskAction="CheckExists" conditionaly so that I do not call a task if the application I am checking for does not exist.

I have tried the following (script below) which when task RemoveApplication is called then task CheckAppExists is called as it is a dependant task. If the application does exist task CheckAppExists sets the ItemName value to 'true'. Then if ItemName has the value 'true' task RemoveApplication_1 is called.

This is really a usage question but I am new to MSBuild and the extensions and am finding it dificult to determine how to construct condtitional scripts.

 

many thanks, Geoff

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<Target Name="RemoveApplication" DependsOnTargets="CheckAppExists">
        <CallTarget Targets="RemoveApplication_1"  Condition="$(ApplicationExists)=='True'"/>
    </Target>
    
    <Target Name="RemoveApplication_1">
        <Exec Command="BTSTask RemoveApp -ApplicationName:$(ProductName) -Server:$(BizTalkDatabaseServerName) -Database:$(BizTalkManagementDatabaseName)" />
    </Target>
    
<Target Name="CheckAppExists" >
            <MSBuild.ExtensionPack.BizTalk.BizTalkApplication TaskAction="CheckExists" Application="$(ProductName)">
                        <Output TaskParameter="Applications" ItemName="ApplicationExists"/>
            </MSBuild.ExtensionPack.BizTalk.BizTalkApplication>
 </Target> 

 

 

 

Developer
Nov 26, 2009 at 2:46 PM

You can just use the Delete task action. it will delete the app only if it exists.

I've noticed a flaw in the docs re the checkexists syntax. I'll fix it.