• Plugin从Sync改为Async后报Could not load file or assembly错误


    问题:之前运行好好的一个PLUGIN,PostCreate,Synchronous

    这次想改成异步的,结果设定为Asynchronous之后,在系统作业中发现全部运行失败了,


    打开看到详细信息如下:

    Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
       at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
       at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
       at System.Activator.CreateInstance(Type type, Boolean nonPublic)
       at System.Activator.CreateInstance(Type type)
       at Microsoft.Crm.Asynchronous.VersionedProxyPluginBase.CreatePlugin[T](Type pluginType, AsyncExecutionContext context)
       at Microsoft.Crm.Asynchronous.V5ProxyPlugin..ctor(Type type, AsyncExecutionContext context, Boolean& isValid)
       at Microsoft.Crm.Asynchronous.EventOperation.InternalExecute(AsyncEvent asyncEvent)
       at Microsoft.Crm.Asynchronous.AsyncEventHandlerCommand`1.Execute(IAsyncEvent asyncEvent)
       at Microsoft.Crm.Asynchronous.AsyncEventExecutionManager`2.ExecuteCommand(IAsyncEventHandlerFactory handlerFactory)
       at Microsoft.Crm.Asynchronous.AsyncEventExecutionManager`2.ExecuteHandler(IAsyncEventHandlerFactory handlerFactory)
       at Microsoft.Crm.Asynchronous.PoolHandler.ProcessAsyncEvent(IAsyncEventExecutionManager asyncEventExecutionManager)
    Inner Exception: System.TypeInitializationException: The type initializer for '******.MSCrm.Plugins.new_******' threw an exception.
       at ******.MSCrm.Plugins.******..ctor()
    Inner Exception: System.IO.FileNotFoundException: Could not load file or assembly 'log4net, Version=1.2.9.0, Culture=neutral, PublicKeyToken=b32731d11ce58905' or one of its dependencies. The system cannot find the file specified.
       at ******.MSCrm.Plugins.new_******..cctor()
    

    发现是由于找不到第三方的dll【log4net.dll】造成,因为在PLUGIN当中引用了该dll写log。那为什么之前Sync的时候就可以,改成Async就不行了呢?
    原来是因为之前把log4net.dll放到了前端服务器的D:Program FilesMicrosoft Dynamics CRMCRMWebin目录下,但是如果改成Async时就应该log4net.dll放到异步服务所在的服务器的CRM安装目录下,并且详细目录和Sync稍有不同,应该放在D:Program FilesMicrosoft Dynamics CRMServerin目录下。

    备注:

    • 文件放进去之后并不会马上生效,需要重启异步服务所在的服务器
    • 异步作业读取的config文件不再是web.config,而是位于D:Program FilesMicrosoft Dynamics CRMServerin目录下的CrmAsyncService.exe.config文件
  • 相关阅读:
    关于fft后图像的纵轴问题
    matlab 与 modelsim 联调 cic抽取滤波器
    z变换的性质
    转载 iir直接i型和直接ii型滤波器
    第十六篇:初探IO复用
    第十五篇:关于TCP通信程序中数据的传递格式
    第十四篇:回射程序中的异常分析
    第十三篇:并发回射服务器的具体实现及其中僵尸子进程的清理( 下 )
    loj 1031(区间dp+记忆化搜索)
    loj 1150(spfa预处理+二分+最大匹配)
  • 原文地址:https://www.cnblogs.com/cndota2/p/12097988.html
Copyright © 2020-2023  润新知