locked
SSIS solution can't reference CRM assemblies RRS feed

  • Question

  • I've just built a simple test SSIS import solution that will pull records from a SQL staging table and then integrate them into CRM.  The problem I'm experiencing is any reference to CRM assemblies is raising errors as follows:

    Could not load file or assembly 'Microsoft.Xrm.Client, Version=5.0.9689.2166, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

    Could not load file or assembly 'Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

    The first error occurred when referencing the object Microsoft.Xrm.Client.CrmConnection in code.  The second error occurred when referencing the object Microsoft.Xrm.Sdk.OrganizationServiceProxy in code.

    Any ideas why our SSIS solution is having issues referencing these CRM assemblies or if we're missing dependent assemblies?

    We're currently running CRM2011 UR11 and using Business Intelligence for Visual Studio 2012 to build the SSIS project.

    Wednesday, June 4, 2014 1:37 PM

All replies

  • I guess you need this assembly in GAC, refer following article for this..

    http://a33ik.blogspot.co.uk/2012/02/integrating-crm-2011-using-sql.html

    MayankP
    My Blog
    Follow Me on Twitter

    Wednesday, June 4, 2014 2:03 PM
    Answerer
  • Hi Mayankp,

    I was actually using an updated article from the same site as my walkthrough for creating the SSIS solution since it refers to CRM2011 and VS2012 Integration Services - http://a33ik.blogspot.ca/2012/11/integrating-crm-2011-using-sql.html

    However, there is no mention of adding the DLL's to the GAC, and the screenshot in the article when the assemblies are added show them coming form the SDK folder and not the GAC.

    I've also read some other articles on using SSIS to integrate with CRM and none of them mention the GAC.   Is there another article that explains this requirement as I'm not sure why the SSIS Solution can't locate the assembly reference I've provided if it's not in the GAC.   Just to be clear, I'm still trying to run this from within Visual Studio as I haven't gotten to the deployment stage into SQL Server.

    Wednesday, June 4, 2014 2:36 PM
  • SSIS will look for assemblies in different locations, depending on what you're doing. The normal recommendation is to place assemblies both in the GAC and the <SQL Server version>\DTS\PipelineComponents directory. When do you get the error ? (e.g. at design time, when debugging the package from Visual Studio, or when running otherwise (e.g. Package Execution Utility))

    It's quite possible that, in the article referenced, the assemblies are already in the GAC, either through other development, or because SSIS is on the CRM server.

    So, I'd either put the assemblies in the locations in my first paragraph, or you could use the Fusion Log viewer to get more information about where SSIS is trying to load the assemblies from (and which assemblies)


    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Wednesday, June 4, 2014 5:37 PM
    Moderator
  • Hi David,

    I was getting the error when running the package in Visual Studio.  It occurred in the PreExecute() method when I referenced the CRM objects.  

    I actually just recently copied the CRM assemblies to the DTS Binn directory and now it executes without error on our development server.  Should I move the DLL's to the PipelineComponents directory instead?  Also, I haven't yet copied the DLL's to the GAC so is this even needed if it's running without error now?  

    I guess I'm not sure why SSIS requires the assemblies in both a DTS directory and registered in the GAC.  It would be so much easier if they bundled these into the DTS package itself, similar to how DLL references are bundled with a CRM Plugin project.

    Wednesday, June 4, 2014 5:50 PM
  • An alternative to the GAC, for instance when the assemblies aren't strong-named, is to manually resolve the assemblies in you script assembly by installing an AssemblyResolve event. eg

    [Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    {
      static ScriptMain()
      {
        AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
      }
      static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
      {
        if (args.Name.Contains("ssisHelper"))
        {
          string path = @"c:\temp\";
          return System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(path,"ssisHelper.dll"));
        }
        return null;
    }
    

    You would typically then use a package variable to indicate the location of the assemblies.

    David


    David http://blogs.msdn.com/b/dbrowne/

    Wednesday, June 4, 2014 5:58 PM
  • Hi

    I am getting the same error for .Net Framework 4.5.2 and MS CRM 2016 online v8.0. I tried everything, copied assemblies to GAC and to DTS Binn folder also but still getting the same error "Could not load file or assembly 'Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified". I am getting error while executing the package, please suggest.

    Wednesday, May 25, 2016 9:14 PM