且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

包URL和单元测试。我的环境问题?

更新时间:2023-12-04 08:45:52

我得到了这个问题,一旦被咬过...

I got bitten by this problem once too...

引用的组件是不够的。 WPF需要调用 System.UriParser.Register()与自己的URI语法分析器,使的System.Uri 可以跨preT包的URL。

Referencing the assemblies isn't enough. WPF needs to call System.UriParser.Register() with its own URI parser so that System.Uri can interpret pack URLs.

反射告诉我们,这是由 System.IO.Packaging.PackUriHelper 的静态构造函数中完成。调用这个类中的任何方法,在您的测试,如 PackUriHelper.Create(),以确保URI解析器以及注册。那种丑陋的,但应该工作。

Reflecting tells us that this is done by the static constructor of System.IO.Packaging.PackUriHelper. Call any method of this class in your test, like PackUriHelper.Create() to ensure the URI parser is well registered. Kind of ugly, but should work.