Why can't I get Type.GetType() to find the type of my plugin instance referenced in app.config?

前端 未结 3 1973
情话喂你
情话喂你 2021-01-21 04:06

So here\'s the deal. I\'ve got my solution which has a few projects in it:

  • A wrapper project - this is just a console app that\'s currently standing in for a wind
相关标签:
3条回答
  • 2021-01-21 04:19

    Is pluginTypeName using assembly-qualified naming? Is the Assembly that contains pluginTypeName showing as being loaded?

    If you're using the Assembly-qualified name then .NET should be able to automatically load the assembly for you; if you aren't then I would guess that Type.GetType() is returning null since it can't locate an assembly containing the requested type.

    0 讨论(0)
  • 2021-01-21 04:25

    Instead of calling Type.GetType(pluginTypeName), try Type.GetType(pluginTypeName, true). The boolean parameter indicates if the call should throw an exception in the event of a failure, instead of returning null - this way, you should get a (hopefully) better description of why GetType is failing instead of just a mysterious null!

    0 讨论(0)
  • 2021-01-21 04:37

    It could be that you need to specify which assembly the type is located in:

    <add key="Plugin" value="Prototypes.BensPlugin, TheAssemblyName" />
    
    0 讨论(0)
提交回复
热议问题