简体   繁体   English

MissingMethodException插件CRM2011

[英]MissingMethodException Plugin CRM2011

I found a couple of suggestions on this question but I can't get it on my problem. 我在这个问题上找到了一些建议,但我无法解决。

We got a .ddl which replaces placeholders in a word file and returned a memorystream. 我们得到了一个.ddl来替换word文件中的占位符,并返回了一个内存流。 This works fine in a deliverd Test Application with a WPF FrontEnd. 在带有WPF FrontEnd的交付测试应用程序中,这可以很好地工作。

Now we need this solution in a CRM2011 context. 现在,我们需要在CRM2011上下文中使用此解决方案。 I added a reference to this .dll file in my CRM Project, build the logic exactly the way as seen in the example and boom a MissingMethodException appears. 我加入到这一参考.dll文件在我的CRM项目文件,建立逻辑完全相同的方式出现在例如和繁荣一个MissingMethodException出现。

I debuged to the point where the Exception is thrown and found somethine like this: 我调试到抛出异常的地步,发现这样的东西:

    readonly Dictionary<Type, object> typeMap = new Dictionary<Type, object>();

/// <summary>
/// Returns an instance of the DataService implementing the <typeparamref name="TService"/> interface
/// </summary>
/// <typeparam name="TService">type of the interface for the DataService</typeparam>
/// <returns></returns>
public TService For<TService>()
{
  if (typeMap.ContainsKey(typeof(TService)))
  {
    object value = typeMap[typeof(TService)];
    if (value is Type)
    {
      return (TService)Activator.CreateInstance((Type)typeMap[typeof(TService)]);
    }

    return (TService)value;
  }

  return Activator.CreateInstance<TService>();
}

The line Activator.CreateInstance(); 行Activator.CreateInstance(); throws the Exception. 引发异常。 I have absolutely no idea what is going wrong here and why this piece of code works fine on the test app. 我绝对不知道这里出了什么问题以及为什么这段代码可以在测试应用程序上正常工作。

I'm assuming it's because you are either attempting to create a Static class, or a class without an empty constructor. 我假设这是因为您正在尝试创建一个静态类,或者一个没有空构造函数的类。 Add try catch that displays the type that is attempting to be created to narrow down what is happening. 添加尝试捕获,该捕获将显示尝试创建的类型以缩小范围。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM