Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Sandbox Worker processes are currently available

$
0
0

Hi

i create new plugin and i keep getting Sandbox Worker processes are currently available error 

if i remove the content code it will run and i'm not able to debug it also 

this is my code 

using Microsoft.Xrm.Sdk;
using System;

namespace Asset_Managment.Plugin
{
    public class Asset_Worker : IPlugin
    {
        #region Secure/Unsecure Configuration Setup
        private string _secureConfig = null;
        private string _unsecureConfig = null;

        public Asset_Worker(string unsecureConfig, string secureConfig)
        {
            _secureConfig = secureConfig;
            _unsecureConfig = unsecureConfig;
        }
        #endregion
        public void Execute(IServiceProvider serviceProvider)
        {
            ITracingService tracer = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
            IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
            IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
            IOrganizationService service = factory.CreateOrganizationService(context.UserId);

            try
            {
                Entity entity = (Entity)context.InputParameters["Target"];
                Asset asset = new Asset();
                asset.Id = entity.Id;
                if (entity.Attributes.Contains(Asset.F_BILL_NUMBER))
                    asset.BillNumber = entity[Asset.F_BILL_NUMBER].ToString();
                if (entity.Attributes.Contains(Asset.F_LOCATION))
                {
                    switch ((entity[Asset.F_LOCATION] as OptionSetValue).Value)
                    {
                        case (int)Asset_Location.Company:
                            asset.Location = Asset_Location.Company;
                            break;
                        case (int)Asset_Location.Customer:
                            asset.Location = Asset_Location.Customer;
                            break;
                        case (int)Asset_Location.Vendor:
                            asset.Location = Asset_Location.Vendor;
                            break;
                    }
                }
                if (entity.Attributes.Contains(Asset.F_LOCATION_ACCOUNT))
                    asset.LocationAccount = new Account { Id = (entity[Asset.F_LOCATION_ACCOUNT] as EntityReference).Id, Name = (entity[Asset.F_LOCATION_ACCOUNT] as EntityReference).Name };
                if (entity.Attributes.Contains(Asset.F_OWNERSHIP))
                {
                    switch ((entity[Asset.F_OWNERSHIP] as OptionSetValue).Value)
                    {
                        case (int)Asset_Ownership.Company:
                            asset.Ownership = Asset_Ownership.Company;
                            break;
                        case (int)Asset_Ownership.Customer:
                            asset.Ownership = Asset_Ownership.Customer;
                            break;
                        case (int)Asset_Ownership.Vendor:
                            asset.Ownership = Asset_Ownership.Vendor;
                            break;
                    }
                }
                if (entity.Attributes.Contains(Asset.F_PURCHASE_DATE))
                    asset.PurchaseDate = TimeZoneInfo.ConvertTimeFromUtc(DateTime.Parse(entity[Asset.F_PURCHASE_DATE].ToString()), TimeZoneInfo.FindSystemTimeZoneById("Arabian Standard Time"));
                if (entity.Attributes.Contains(Asset.F_PURCHASE_VALUE))
                    asset.PurchaseValue = (entity[Asset.F_PURCHASE_VALUE] as Money).Value;
                if (entity.Attributes.Contains(Asset.F_RETURN_DATE))
                    asset.ReturnDate = TimeZoneInfo.ConvertTimeFromUtc(DateTime.Parse(entity[Asset.F_RETURN_DATE].ToString()), TimeZoneInfo.FindSystemTimeZoneById("Arabian Standard Time"));
                if (entity.Attributes.Contains(Asset.F_SERIAL_NUMBER))
                    asset.SerialNumber = entity[Asset.F_SERIAL_NUMBER].ToString();
                if (entity.Attributes.Contains(Asset.F_SYSTEM_STATUS))
                {
                    switch ((entity[Asset.F_SYSTEM_STATUS] as OptionSetValue).Value)
                    {
                        case (int)Asset_System_Status.New:
                            asset.SystemStatus = Asset_System_Status.New;
                            break;
                    }
                }
                if (entity.Attributes.Contains(Asset.F_VENDOR))
                    asset.Vendor = new Account { Id = (entity[Asset.F_VENDOR] as EntityReference).Id, Name = (entity[Asset.F_VENDOR] as EntityReference).Name };
                if (entity.Attributes.Contains(Asset.F_WAREHOUSE))
                    asset.Warehouse = new Warehouse { Id = (entity[Asset.F_WAREHOUSE] as EntityReference).Id, Name = (entity[Asset.F_WAREHOUSE] as EntityReference).Name };
                if (entity.Attributes.Contains(Asset.F_WARRANTY_END_DATE))
                    asset.WarrantyEndDate = TimeZoneInfo.ConvertTimeFromUtc(DateTime.Parse(entity[Asset.F_WARRANTY_END_DATE].ToString()), TimeZoneInfo.FindSystemTimeZoneById("Arabian Standard Time"));
                service.Create(asset.CreateFirstLogTransaction());
            }
            catch (Exception e)
            {
                throw new InvalidPluginExecutionException(e.Message);
            }
        }
    }
}

this is the error 

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: The plug-in execution failed because no Sandbox Worker processes are currently available. Please try again.
System.ServiceModel.CommunicationException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #B0FDB70CDetail: 
<OrganizationServiceFault xmlns:i="www.w3.org/.../XMLSchema-instance" xmlns="schemas.microsoft.com/.../Contracts">
  <ErrorCode>-2147204723</ErrorCode>
  <ErrorDetails xmlns:d2p1="schemas.datacontract.org/.../System.Collections.Generic" />
  <Message>The plug-in execution failed because no Sandbox Worker processes are currently available. Please try again.
System.ServiceModel.CommunicationException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #B0FDB70C</Message>
  <Timestamp>2016-11-02T08:45:13.5841161Z</Timestamp>
  <InnerFault i:nil="true" />
  <TraceText>

[Asset_Managment.Plugin: Asset_Managment.Plugin.Asset_Worker]
[748fc928-d6a0-e611-80f3-5065f38a5a21: Asset_Managment.Plugin.Asset_Worker: Create of ets_asset]


</TraceText>
</OrganizationServiceFault>



Viewing all articles
Browse latest Browse all 46379

Trending Articles