Showing posts with label BUG. Show all posts
Showing posts with label BUG. Show all posts

Monday, 29 October 2018

Bug: Script Task - Cannot load script for execution

Case
My Script Tasks are running fine in Visual Studio 2017, but when deployed to the catalog I get an error in all Script Tasks: Cannot load script for execution
Error: Cannot load script for execution










Solution
There is a bug in SSDT for Visual Studio 2017 (15.8.1). The (temporary) workaround is to NOT use SSDT 2017 for deployment. Instead you could use SSMS to deploy your SSIS projects.
Deploy packages with SSMS



















Or use ISDeploymentWizard.exe in the folder C:\Program Files (x86)\Microsoft Visual Studio\2017\SQL\Common7\IDE\CommonExtensions\Microsoft\SSIS\150\Binn\  to deploy your projects.

Expect an update soon!


UPDATE: SSDT 15.8.2 is available
Fixed an issue that deploying SSIS project which contains packages containing Script Task/Flat file destination to Azure-SSIS will result in the packages failing to execute in Azure-SSIS






Wednesday, 23 August 2017

Where is the new SSIS project type?

Case
I just downloaded the new SSDT for Visual Studio 2017 (15.3.0 preview) and although I selected Integration Services during installation it isn't showing in the New Project window.
SSDT for Visual Studio 2017 (15.3.0 preview)























Solution
You probably already had Visual Studio 2017 installed and added the Analysis Services and Reporting Services project types via Extensions and Updates.


1) Remove projects
Go to Extensions and Updates and remove both the Analysis Services and Reporting Services projects.
Remove SSAS and SSRS projects



















After that close Visual Studio and let the VSIX installer, uninstall both projects.
VSIX (un)installer

















2) Uninstall SSDT and Install SSDT
Then first uninstall SSDT completely. And then install SSDT (Repair didn't work).
Uninstall and install SSDT






















3) Create new SSIS Project
Now open Visual Studio and create a new SSIS project.
New SSIS Project







Thursday, 29 December 2016

Deployment bug SSIS VNEXT missing reference

Case
When deploying a project from SSDT VNEXT (SQL Server Data Tools 17.0 RC1) I get an error.
Could not load file or assembly
'Microsoft.SqlServer.Management.IntegrationServicesEnum, Culture=neutral,
PublicKeyToken=89845dcd8080cc91' or one of its dependencies.
The system cannot find the file specified. (mscorlib)


























Solution
SSDT 17.0 RC1 still got some bugs, for real projects you should use SSDT 16.5 But if you want to discover for example the Scale Out function or Support for Microsoft Dynamics Online Resources of SQL VNEXT then you should/could use this version.

Three solutions (in order of recommendation):
  1. Since this bug only occurs in SSDT, you could deploy outside SSDT with PowerShell of by just double clicking the ISPAC file. Then this error won't occur.
  2. It's a known issue. Just wait for the next release of SSDT (early 2017).
  3. Or add the missing reference to <drive>:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe.config and restart SSDT (at your own risk of course)
Add missing reference
















<dependentAssembly>
    <assemblyIdentity name="Microsoft.SqlServer.Management.IntegrationServicesEnum" publicKeyToken="89845dcd8080cc91" culture="neutral"/>
    <bindingRedirect oldVersion="13.0.0.0-14.100.0.0" newVersion="13.0.0.0"/>
</dependentAssembly>
Solved

Saturday, 1 August 2015

Renaming project during deployment Ispac file

Case
I have an SSIS project in Visual Studio which is called "01 StageFinance". The prefix is to preserve the order of projects in the Visual Studio solution.
Solution Explorer inVisual Studio












When I manually deploy the Ispac file to the Catalog, I have the possibility to rename the project from "01 StageFinance" to "StageFinance".

Possible to rename project in Wizard















But when I deploy the Ispac file via Powershell or TSQL then it returns an error when I rename the prject name: Failed to deploy the project. Fix the problems and try again later.:The specified project name, StageFinance, does not match the project name in the deployment file. Why do I need to provide the project name if I can't change it?

Solution
I used the SQL Server Profiler to see what happens during deployment. Both the Wizard and the PowerShell script call the stored procedure deploy_project

exec [SSISDB].[catalog].[deploy_project]
@folder_name=N'Finance',@project_name=N'StageFinance',@project_stream=0x504B0304



What struc to me was that the Wizard called the stored procedure with the new/changed name and then it didn't fail. And when I tried that with powershell it failed.

$NewProjectName = "StageFinance"
[byte[]] $IspacFile = [System.IO.File]::ReadAllBytes($IspacFilePath)
$Folder.DeployProject($NewProjectName, $IspacFile) 

Conclusion: The ispac file was probably modified by the Wizard. Next I unzipped the Ispac file and edited the file @Project.manifest and saw that line 4 contained the project name.
@Project.manifest








I changed that project name to "StageFinance", zipped all the files and renamed the zipfile to .Ispac. Then I deployed the new Ispac file without any errors! Doing that manually each time the project needs to be deployed is annoying.

Automate rename with PowerShell
Recently I posted a PowerShell deployment script for automatic deployment. I added a sectio to that script to do the project rename:
# Partial Script
############################
########## RENAME ##########
############################
# If the filename and projectname are different
# Then we need to rename the internal projectname
# before deploying it.

# Derive projectname from ISPAC filename
$CurrentProjectName = [system.io.path]::GetFileNameWithoutExtension($IspacFilePath)

# Check if rename is necessary
If (-not($CurrentProjectName -eq $ProjectName))
{
    # Split filepath of ispac file in folder and file
    $TmpUnzipPath = split-path $IspacFilePath -Parent
    # Determine the filepath of the new ispac file
    $NewIspacFilePath = $TmpUnzipPath + "\" + $ProjectName + ".ispac"
    # Determine the path of the unzip folder
    $TmpUnzipPath = $TmpUnzipPath + "\" + $CurrentProjectName
    
    # Catch unexpected errors and stop script
    Try
    {
        # Check if new ispac already exists
        if (Test-Path $NewIspacFilePath)
        {
            [System.IO.File]::Delete($NewIspacFilePath)
        }

        # Search strings
        $SearchStringStart = ''
        $SearchStringEnd = ''
 
        # Add reference to compression namespace
        Add-Type -assembly "system.io.compression.filesystem"

        # Extract ispac file to temporary location (.NET Framework 4.5) 
        [io.compression.zipfile]::ExtractToDirectory($IspacFilePath, $TmpUnzipPath)

        # Replace internal projectname with new projectname
        $EditFile = $TmpUnzipPath + "\@Project.manifest"
        (get-content $EditFile).replace($SearchStringStart + $CurrentProjectName + $SearchStringEnd, $SearchStringStart + $ProjectName + $SearchStringEnd) | set-content $EditFile

        # Zip temporary location to new ispac file (.NET Framework 4.5) 
        [io.compression.zipfile]::CreateFromDirectory($TmpUnzipPath, $NewIspacFilePath)

        # Delete temporary location
        [System.IO.Directory]::Delete($TmpUnzipPath, $True)

        # Replace ispac parameter
        $IspacFilePath = $NewIspacFilePath
    }
    Catch [System.Exception]
    {
        Throw  [System.Exception] "Failed renaming project in $IspacFileName : $_.Exception.Message "
    }
}

The complete script can be downloaden here.



Thanks to Bill Fellows for pointing me in the right direction.

Saturday, 16 May 2015

Timeout after 30 seconds when executing package via .NET

Case
I'm executing a package via .NET (example 1, example 2), but if the packages takes more than 30 seconds I get an error: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding. Changing the timeout in the connection string to for example 300 has no effect.

// C# Code (incorrect)
// Connection to the database server where the packages are located
using (SqlConnection ssisConnection = new SqlConnection("Data Source=.;Initial Catalog=master;Integrated Security=SSPI;Connection Timeout=300")
{
  try
  {
    // SSIS server object with connection
    IntegrationServices ssisServer = new IntegrationServices(ssisConnection);
    
    // The reference to the package which you want to execute
    PackageInfo ssisPackage = ssisServer.Catalogs["SSISDB"].Folders["SSISJoost"].Projects["MyProject"].Packages["MyPackage.dtsx"];

    // Add execution parameter to override the default asynchronized execution. If you leave this out the package is executed asynchronized
    Collection<PackageInfo.ExecutionValueParameterSet> executionParameter = new Collection<PackageInfo.ExecutionValueParameterSet>();
    executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 50, ParameterName = "SYNCHRONIZED", ParameterValue = 1 });

    // Add a package parameter
    executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 30, ParameterName = "myStringParam", ParameterValue = "some value" });

    // Get the identifier of the execution to get the log
    long executionIdentifier = ssisPackage.Execute(false, null, executionParameter);
  }
  catch (exception ex)
  {
    // Log code for exceptions
  }
}


Solution
The 30 seconds is the default timeout which apparently can't be changed in the ssisPackage.Execute command. The solution is a little dirty. First remove the SYNCHRONIZED parameter to execute the package asynchronized. Then add some code after the ssisPackage.Execute command.
// C# Code (correct)
using (SqlConnection ssisConnection = new SqlConnection("Data Source=.;Initial Catalog=master;Integrated Security=SSPI;"))
{
  try
  {
    // SSIS server object with connection
    IntegrationServices ssisServer = new IntegrationServices(ssisConnection);
    
    // The reference to the package which you want to execute
    PackageInfo ssisPackage = ssisServer.Catalogs["SSISDB"].Folders["SSISJoost"].Projects["MyProject"].Packages["MyPackage.dtsx"];

    // Add execution parameter to override the default asynchronized execution. If you leave this out the package is executed asynchronized
    Collection<PackageInfo.ExecutionValueParameterSet> executionParameter = new Collection<PackageInfo.ExecutionValueParameterSet>();
    //executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 50, ParameterName = "SYNCHRONIZED", ParameterValue = 1 });

    // Add a package parameter
    executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 30, ParameterName = "myStringParam", ParameterValue = "some value" });

    // Get the identifier of the execution to get the log
    long executionIdentifier = ssisPackage.Execute(false, null, executionParameter);

    // Get execution details with the executionIdentifier from the previous step
    ExecutionOperation executionOperation = ssisServer.Catalogs["SSISDB"].Executions[executionIdentifier];

    // Workaround for 30 second timeout:
    // Loop while the execution is not completed
    while (!(executionOperation.Completed))
    {
      // Refresh execution info
      executionOperation.Refresh();
   
      // Wait 5 seconds before refreshing (we don't want to stress the server)
      System.Threading.Thread.Sleep(5000);
    }
  }
  catch (exception ex)
  {
    // Log code for exceptions
  }
}
Thanks to SequelMate and HansAnderss
Related Posts Plugin for WordPress, Blogger...