Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to register multiple plugin steps #282

Open
simba22042 opened this issue Oct 25, 2018 · 10 comments
Open

How to register multiple plugin steps #282

simba22042 opened this issue Oct 25, 2018 · 10 comments

Comments

@simba22042
Copy link

I have a base class where different overrides for different plugins steps. How do I register different steps using the same plugin class using spkl.

I am providing what I have. spkl registers only the first step.

` [CrmPluginRegistration(MessageNameEnum.Create,"account", StageEnum.PreValidation, ExecutionModeEnum.Synchronous,"","Pre Create Account",1000,
IsolationModeEnum.Sandbox)]
[CrmPluginRegistration(MessageNameEnum.Create, "account", StageEnum.PostOperation, ExecutionModeEnum.Synchronous, "", "Post Create Account", 1001,
IsolationModeEnum.Sandbox)]

public class AccountPlugin : PluginBase
{
    /// <summary>
    /// 
    /// </summary>
    /// <param name="serviceProvider"></param>
    /// <param name="pluginExecutionContext"></param>
    /// <param name="organizationService"></param>
    /// <param name="tracingService"></param>
    /// <param name="inputTargetEntity"></param>
    
    public override void HandleBeforePreOpCreate(IServiceProvider serviceProvider, IPluginExecutionContext pluginExecutionContext, IOrganizationService organizationService, ITracingService tracingService, Entity inputTargetEntity)
    {
        base.HandleBeforePreOpCreate(serviceProvider, pluginExecutionContext, organizationService, tracingService, inputTargetEntity);


    }

    public override void HandleAfterOpCreate(IServiceProvider serviceProvider, IPluginExecutionContext pluginExecutionContext, IOrganizationService organizationService, ITracingService tracingService, Entity inputTargetEntity, Guid outPutId)
    {
        base.HandleAfterOpCreate(serviceProvider, pluginExecutionContext, organizationService, tracingService, inputTargetEntity, outPutId);
    }
}`
@scottdurow
Copy link
Owner

This is certainly a supported scenario - what version are you using?

@simba22042
Copy link
Author

simba22042 commented Oct 25, 2018

It’s the latest version. I did a rebuild and then seem to register the two steps. Thanks.

FYI- I purchased your video on Dynamics 365 from PACKT. It’s great. Thank you again for sharing with us.

@simba22042
Copy link
Author

My other question I have published a merged plugin and when I try to unpack the meta data for steps nothing gets processed.

@scottdurow
Copy link
Owner

When you say ‘Merged’ do you mean ILMerge? If so - http://develop1.net/public/post/2018/10/21/ILMergeNotSupported

@scottdurow
Copy link
Owner

Are you all set now?

@simba22042
Copy link
Author

Sorry for a late response no this has never worked with a merged plugin.

Deploying Plugins
Searching for plugin config in 'C:\XXXX_VSTS\Engage\Version 2.0\Current\XXXX.Crm - Copy\sf365Plugins\spkl\..'
Using Config 'C:\XXXX_VSTS\Engage\Version 2.0\Current\XXXX.Crm - Copy\sf365Plugins'
Checking assembly 'sf365MergedPlugin.dll' for plugins
3 plugin(s) found!
Updating Plugin 'sf365MergedPlugin' from 'C:\XXXX_VSTS\Engage\Version 2.0\Current\XXXX.Crm - Copy\sf365Plugins\bin\Debug\Deploy\sf365MergedPlugin.dll'
Adding Plugin 'sf365MergedPlugin' to solution 'sf365'
Adding to solution 'sf365'
Updating Type 'sf365Plugins.AccountPlugin'
Updating Step 'Pre Create Account'
Adding to solution 'sf365'
Updating Step 'Post Create Account'
Adding to solution 'sf365'
Checking assembly 'XXX.PluginCommon.dll' for plugins
2 plugin(s) found!
Checking assembly 'sf365Plugins.dll' for plugins
1 plugin(s) found!
Updating Plugin 'sf365Plugins' from 'C:\XXXX_VSTS\Engage\Version 2.0\Current\XXXX.Crm - Copy\sf365Plugins\bin\Debug\sf365Plugins.dll'
Registering Type 'sf365Plugins.AccountPlugin'
The application terminated with an error.
Timestamp: 12/7/2018 1:59:03 PM
Code: -2147204725
Message: Plug-in assembly does not contain the required types or assembly content cannot be updated.

Server stack trace:
   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at Microsoft.Xrm.Sdk.IOrganizationService.Create(Entity entity)
   at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.CreateCore(Entity entity)
   at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.Create(Entity entity)
   at SparkleXrm.Tasks.PluginRegistraton.RegisterPluginSteps(IEnumerable`1 pluginTypes, PluginAssembly plugin)
   at SparkleXrm.Tasks.PluginRegistraton.RegisterPlugin(String file)
   at SparkleXrm.Tasks.DeployPluginsTask.DeployPlugins(OrganizationServiceContext ctx, ConfigFile config)
   at SparkleXrm.Tasks.DeployPluginsTask.ExecuteInternal(String folder, OrganizationServiceContext ctx)
   at SparkleXrm.Tasks.BaseTask.Execute(String folder)
   at SparkleXrmTask.Program.RunTask(CommandLineArgs arguments, IOrganizationService service, ITrace trace)
   at SparkleXrmTask.Program.Run(CommandLineArgs arguments)
   at SparkleXrmTask.Program.Main(String[] args)
Inner Fault: Has Inner Fault
Press any key to continue . . .

@simba22042
Copy link
Author

I checked the plugin through plugin registration tool it looks like it registered my steps on the merged plugin but the spkl task runner is trying to register the un merged plugin. How do tell spkl to exclude some plugin assemblies.

@simba22042
Copy link
Author

I also noticed it cannot instrument the plugin code when its a merged plugin. Nice to have but I can do without it.

@mattp65
Copy link
Contributor

mattp65 commented Dec 7, 2018

I would recomend putting your Merged assembly in a seperate directory and setting SPKL up so it only processes that directory and not the one containing the Unmerged code. If your Unmerged assembly has the tags in place for registering steps, SPKL is going to try to process it. There is no reasonable way for it to know to bypass it as it was setup to process based on a folder.

Also, I recommend reviewing the article Scott linked to above about ILMerge not being supported. If this is just to include internal code, look to Shared Projects as an alternative to pull in the source without using ILMerge.

@simba22042
Copy link
Author

I am also merging some third party assembly i.e. Authorize.NET for collecting payments using the CRM Forms. I have been using ILMerge since 2011 days and never ran into any issues yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants