RuleSetDialog 和引用的程序集
我试图在生产站点上打开 RuleSetDialog 表单,但它崩溃并显示消息:
FileNotFoundException: Could not load file or assembly 'IBM.Data.Informix, Version=9.0.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208' or one of its dependencies. The system cannot find the file specified.
问题是,此程序集在我们的项目中被引用,但它在生产站点上不存在,因为不同将使用数据库。
这是堆栈跟踪:
at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at System.Workflow.Activities.Rules.SimpleRunTimeTypeProvider.get_ReferencedAssemblies()
at System.Workflow.Activities.Rules.SimpleRunTimeTypeProvider.GetTypes()
at System.Workflow.Activities.Rules.Parser..ctor(RuleValidation validation)
at System.Workflow.Activities.Rules.Design.RuleSetDialog..ctor(Type activityType, ITypeProvider typeProvider, RuleSet ruleSet)
我不知道该怎么做。在开发和测试过程中,一切都运行良好,因为我们的机器安装了所有驱动程序,但对于仅安装所需驱动程序的用户来说,情况并非如此。
I'm trying to open a RuleSetDialog form on a production site but it crashes with message:
FileNotFoundException: Could not load file or assembly 'IBM.Data.Informix, Version=9.0.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208' or one of its dependencies. The system cannot find the file specified.
The thing is, this assembly is being referenced in our project but it doesn't exist on a production site since different database will be used.
This is the stack trace:
at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at System.Workflow.Activities.Rules.SimpleRunTimeTypeProvider.get_ReferencedAssemblies()
at System.Workflow.Activities.Rules.SimpleRunTimeTypeProvider.GetTypes()
at System.Workflow.Activities.Rules.Parser..ctor(RuleValidation validation)
at System.Workflow.Activities.Rules.Design.RuleSetDialog..ctor(Type activityType, ITypeProvider typeProvider, RuleSet ruleSet)
I'm not sure what to do. Everything worked nicely during development and testing since our machines have all drivers installed but this is not the case with our users who install only the required drivers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
本周我遇到了类似的错误,因为我们所需的 dll 没有部署在应用程序的主文件夹中,而是部署在单独的子文件夹中。我没有找到任何有效的方法来告诉规则引擎在哪里搜索它们。对我来说,侵入 AppDomain 似乎不是最好的解决方案。
就我而言,我用来运行 RuleEngine 的对象没有扩展方法,因此不会直接使用引用的程序集来定义其方法。规则验证不需要引用的程序集。
所以我的解决方法是告诉规则引擎没有引用的程序集。我通过编写自己的 ITypeProvider 并将其传递给 RuleEngine/RuleSetDialog 构造函数的构造函数来完成此操作。
我从 github 的默认 SimpleRunTimeTypeProvider 中获取了代码(https://github.com/rashiph/DecompliedDotNetLibraries/blob/master/System.Workflow.Activities/System/Workflow/Activities/Rules/SimpleRunTimeTypeProvider.cs)并调整了属性 ReferencedAssemblies (评论4 LOC)如下:
I encountered a similar error this week because our needed dll's are not deployed in the application's main folder, but in a separate subfolder. I did not find any working way to tell the RuleEngine where to search for them. Hacking into the AppDomain did not seem the best solution to me.
In my case the object I use to run the RuleEngine does not have Extension methods and so does not directly use referenced assemblies for its method definitions. The referenced assemblies are not needed for rule validation.
So my workaround is to tell the rule-engine that there are no referenced assemblies. This I did by writing my own ITypeProvider and passing that to the constructor of the RuleEngine/RuleSetDialog constructor.
I took the code from the default SimpleRunTimeTypeProvider from github (https://github.com/rashiph/DecompliedDotNetLibraries/blob/master/System.Workflow.Activities/System/Workflow/Activities/Rules/SimpleRunTimeTypeProvider.cs) and adapted the property ReferencedAssemblies (commented 4 LOC) as follows:
我认为这不是最正确的解决方案,但我可以通过将其添加到我的应用程序中来使其工作:
希望这可以帮助某人。
I don't think this is the most correct solution, but I could make it work by adding this to my application:
Hope this can help someone.