mbraceproject / MBrace.Core

MBrace Core Libraries & Runtime Foundations
http://mbrace.io/
Apache License 2.0
209 stars 46 forks source link

Dynamics CRM #166

Closed petarvucetin closed 8 years ago

petarvucetin commented 8 years ago

There are some internals that are breaking when I trying to use Dynamics CRM OrganizationService proxy from withing CloudFlow: I cannot infer what are they doing or why would that break MBrace.

Exception

INFO : Uploading 'FSI-ASSEMBLY_60f7cef6-b0b8-4f24-96df-c70fa6326368_2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' [IMG 4.00 KiB]
INFO : Uploading data dependency 'MBrace.Core.Cloud`1[System.Tuple`3[System.Guid,System.Object, CRM.Contracts.Account][]] x@1-3' [4.81 KiB]
INFO : Posted CloudProcess<(System.Guid * obj * CRM.Contracts.Account) []> '33d69dba-d350-45ea-ac9f-a6b68430585e'.
System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Xrm.Sdk.Client.ServiceMetadataUtility.GetSDKVersionNumberFromAssembly()
   at Microsoft.Xrm.Sdk.Client.ServiceMetadataUtility.RetrieveServiceEndpointMetadata(Type contractType, Uri serviceUri, Boolean checkForSecondary)
   at Microsoft.Xrm.Sdk.Client.ServiceConfiguration`1..ctor(Uri serviceUri, Boolean checkForSecondary)
   at Microsoft.Xrm.Sdk.Client.OrganizationServiceConfiguration..ctor(Uri serviceUri, Boolean enableProxyTypes, Assembly assembly)
   at Microsoft.Xrm.Sdk.Client.ServiceConfigurationFactory.CreateConfiguration[TService](Uri serviceUri, Boolean enableProxyTypes, Assembly assembly)
   at Microsoft.Xrm.Client.Services.OrganizationService.CreateServiceConfiguration(CrmConnection connection)
   at Microsoft.Xrm.Client.Services.OrganizationService.GetServiceConfiguration(CrmConnection connection)
   at Microsoft.Xrm.Client.Services.OrganizationService.ToOrganizationServiceProxy(CrmConnection connection)
   at Microsoft.Xrm.Client.Services.OrganizationService.ToOrganizationService(CrmConnection connection)
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at Microsoft.Xrm.Client.Services.OrganizationService.InnerOrganizationService.UsingService[TResult](Func`2 action)
   at FSI_0005.memberAccountBuilder(Object row)
   at MBrace.Flow.Internals.Consumers.Transformers.map@34-5.Invoke(T x)
   at Nessos.Streams.ParStream.createTask@128-2.Invoke()
   at System.Threading.Tasks.Task.Execute()

Source Code for Microsoft.Xrm.Sdk.Client.ServiceMetadataUtility.GetSDKVersionNumberFromAssembly()

private static double GetSDKVersionNumberFromAssembly()
{
  string[] strArray = OrganizationServiceProxy.GetXrmSdkAssemblyFileVersion().Split('.');
  double result = 0.0;
  if (strArray.Length >= 2)
  {
    if (!double.TryParse(string.Format((IFormatProvider) CultureInfo.InvariantCulture, "{0}.{1}", new object[2]
    {
      (object) strArray[0],
      (object) strArray[1]
    }), out result))
      result = 0.0;
  }
  return result;
}

Source Code For OrganizationServiceProxy.GetXrmSdkAssemblyFileVersion()

[SuppressMessage("Microsoft.Security", "CA2143:TransparentMethodsShouldNotDemandFxCopRule")]
[SuppressMessage("Microsoft.Security", "CA2141:TransparentMethodsMustNotSatisfyLinkDemandsFxCopRule")]
[PermissionSet(SecurityAction.Demand, Unrestricted = true)]
internal static string GetXrmSdkAssemblyFileVersion()
{
  if (string.IsNullOrEmpty(OrganizationServiceProxy._xrmSdkAssemblyFileVersion))
  {
    string[] strArray = new string[1]
    {
      "Microsoft.Xrm.Sdk.dll"
    };
    Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
    foreach (string str in strArray)
    {
      foreach (Assembly assembly in assemblies)
      {
        if (assembly.ManifestModule.Name.Equals(str, StringComparison.OrdinalIgnoreCase))
          OrganizationServiceProxy._xrmSdkAssemblyFileVersion = FileVersionInfo.GetVersionInfo(assembly.Location).FileVersion;
      }
    }
  }
  return OrganizationServiceProxy._xrmSdkAssemblyFileVersion;
}

These are the info messages:

Binding session to 'D:\Development\f#\src\BootstrapLoader\../packages/Streams/lib/net45\Streams.dll'...
Binding session to 'D:\Development\f#\src\BootstrapLoader\..\packages\Dynamics.Crm.Sdk.Clean\lib\Microsoft.Xrm.Sdk.Deployment.dll'...
INFO : Uploading 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [IMG 267.16 KiB]
INFO : Uploading 'MBrace.Flow, Version=1.1.8.0, Culture=neutral, PublicKeyToken=null' [IMG 384.50 KiB]
INFO : Uploading 'System.Runtime.Serialization.Formatters.Soap, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [IMG 138.77 KiB]
INFO : Uploading 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [IMG 0.57 MiB]
INFO : Uploading 'Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [IMG 1.10 MiB]
INFO : Uploading 'Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [IMG 0.62 MiB]
INFO : Uploading 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [IMG 5.80 MiB]
INFO : Uploading 'Microsoft.SqlServer.TransactSql.ScriptDom, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' [IMG 2.75 MiB]
INFO : Uploading 'PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [IMG 3.33 MiB]
INFO : Uploading 'System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [IMG 242.64 KiB]
INFO : Uploading 'System.Drawing.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [IMG 110.22 KiB]
INFO : Uploading 'FSI-ASSEMBLY_60f7cef6-b0b8-4f24-96df-c70fa6326368_1, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' [IMG 72.00 KiB]
INFO : Uploading 'System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [IMG 1.45 MiB]
INFO : Uploading 'System.Runtime.DurableInstancing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [IMG 169.20 KiB]
INFO : Uploading 'System.DirectoryServices.Protocols, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [IMG 195.79 KiB]
INFO : Uploading 'Accessibility, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [IMG 35.09 KiB]
INFO : Uploading 'System.ServiceProcess, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [IMG 131.22 KiB]
INFO : Uploading 'System.Deployment, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [IMG 0.81 MiB]
INFO : Uploading 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [IMG 1.20 MiB]
INFO : Uploading 'System.ServiceModel.Internals, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [IMG 244.27 KiB]
INFO : Uploading 'CRM.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0a2a0089dfd19253' [IMG 4.94 MiB]
INFO : Uploading 'System.ServiceModel.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [IMG 0.53 MiB]
INFO : Uploading 'ReachFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [IMG 0.56 MiB]
INFO : Uploading 'System.Xaml.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [IMG 41.62 KiB]
INFO : Uploading 'Microsoft.VisualBasic.Activities.Compiler, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [IMG 3.05 MiB]
INFO : Uploading 'System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [IMG 122.81 KiB]
INFO : Uploading 'System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [IMG 410.23 KiB]
INFO : Uploading 'System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [IMG 1.76 MiB]
INFO : Uploading 'FSharp.Data.SqlClient, Version=1.8.1.0, Culture=neutral, PublicKeyToken=null' [IMG 0.51 MiB]
INFO : Uploading 'UIAutomationTypes, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [IMG 103.35 KiB]
INFO : Uploading 'System.Activities.DurableInstancing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [IMG 140.71 KiB]
INFO : Uploading 'System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [IMG 69.27 KiB]
**INFO : Uploading 'Microsoft.Xrm.Sdk, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [IMG 485.72 KiB]**
INFO : Uploading 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [IMG 5.10 MiB]
INFO : Uploading 'System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [IMG 4.77 MiB]
INFO : Uploading 'PresentationUI, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [IMG 0.81 MiB]
**INFO : Uploading 'Microsoft.Xrm.Client, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [IMG 284.17 KiB]**
INFO : Uploading 'Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [IMG 1.04 MiB]
INFO : Uploading 'Streams, Version=0.4.1.0, Culture=neutral, PublicKeyToken=null' [IMG 338.00 KiB]
INFO : Uploading 'System.Web.RegularExpressions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [IMG 105.16 KiB]
INFO : Uploading 'System.ServiceModel.Channels, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [IMG 153.24 KiB]
INFO : Uploading 'System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [IMG 0.80 MiB]
INFO : Uploading 'Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [IMG 99.14 KiB]
INFO : Uploading 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [IMG 195.68 KiB]
INFO : Uploading 'System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [IMG 319.73 KiB]
INFO : Uploading 'UIAutomationProvider, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [IMG 48.13 KiB]
INFO : Uploading 'System.Printing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [IMG 358.34 KiB]
**INFO : Uploading 'Microsoft.Xrm.Sdk.Deployment, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [IMG 95.71 KiB]**
INFO : Uploading 'System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [IMG 197.24 KiB]
INFO : Uploading data dependency 'MBrace.Core.Cloud`1[System.Tuple`3[System.Guid,System.Object,CRM.Contracts.Account][]] x@1-1' [4.81 KiB]
INFO : Uploading data dependency 'System.Object[] x@1-2' [4.42 KiB]
palladin commented 8 years ago

It is difficult for us to debug external code without a minimal reproduction sample. A different approach is to package your code as a zip file (.exe, .dlls etc) and let mbrace externally handle the distribution. For more details about this technique check this https://github.com/mbraceproject/MBrace.StarterKit/blob/master/HandsOnTutorial/examples/200-launching-python-example.fsx

petarvucetin commented 8 years ago

Thanks Nick,

I was looking at feasibility of using MBrace as replacement for Integration Services (SSIS) on local machine or as distributed process across Azure cluster. This is similar to Data Factory but not quite the same.

I admit that I am no expert in F# but It is bit confusing why is there limitation for running (anything) .Net as is on MBrace. Again, I apologize for not completely grokking the limitations but my vision is that i would have simple way to create distributed process easily with anything.

If you are interested in the example I can provide one but running .Net code as external (like Python) code is not very appealing to me.

eiriktsarpalis commented 8 years ago

I think I know why the problem occurs, though this is only speculative since I cannot run your actual code. I noticed that your account type (though partial) carries the DataContract attribute however I didn't see any fields or properties carrying the DataMember attribute. This means that we would serialize this type without actually serializing any of its containing fields, which may explain why you're seeing nullref errors. On Sun, 17 Apr 2016 at 04:30, Petar Vučetin notifications@github.com wrote:

Thanks Nick,

I was looking at feasibility of using MBrace as replacement for Integration Services (SSIS) on local machine or as distributed process across Azure cluster. This is similar to Data Factory but not quite the same.

I admit that I am no expert in F# but It is bit confusing why is there limitation for running (anything) .Net as is on MBrace. Again, I apologize for not completely grokking the limitations but my vision is that i would have simple way to create distributed process easily with anything.

If you are interested in the example I can provide one but running .Net code as external (like Python) code is not very appealing to me.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/mbraceproject/MBrace.Core/issues/166#issuecomment-210934795

petarvucetin commented 8 years ago

I see what you mean. I am wondering how does the WCF with its NetDataContractSerializer make this work... (even from F#)

eiriktsarpalis commented 8 years ago

Perhaps it just serializes everything when no datamember is specified. On Sun, 17 Apr 2016 at 21:59, Petar Vučetin notifications@github.com wrote:

I see what you mean. I am wondering how does the WCF with its NetDataContractSerializer make this work... (even from F#)

— You are receiving this because you commented.

Reply to this email directly or view it on GitHub https://github.com/mbraceproject/MBrace.Core/issues/166#issuecomment-211083846

petarvucetin commented 8 years ago

Can NDC be used as default serializer?

eiriktsarpalis commented 8 years ago

No unfortunately, MBrace relies on built-in functionality of FsPickler in order to function properly. That said, you could always pass your objects through NDC explicitly before creating a parallel computation and let mbrace just handle the xml.

Have you tried removing the DataContractAttribute from your Account type? On Sun, Apr 17, 2016 at 22:04 Petar Vučetin notifications@github.com wrote:

Can NDC be used as default serializer?

— You are receiving this because you commented.

Reply to this email directly or view it on GitHub https://github.com/mbraceproject/MBrace.Core/issues/166#issuecomment-211084613

petarvucetin commented 8 years ago

Thanks I will see if that works.

CRM Contracts are autogenerated from service endpoint so I don't have much choice.

eiriktsarpalis commented 8 years ago

were you able to fix the problem? On Mon, 18 Apr 2016 at 22:01, Petar Vučetin notifications@github.com wrote:

Closed #166 https://github.com/mbraceproject/MBrace.Core/issues/166.

— You are receiving this because you commented.

Reply to this email directly or view it on GitHub https://github.com/mbraceproject/MBrace.Core/issues/166#event-631799014

petarvucetin commented 8 years ago

I am unable to move forward because I cannot resolve the problems with contracts nor with CRM WCF service client.