开发者

Prohobit type usage across default or not AppDomain

Is it possible to somehow prevent a type usage across an AppDomain (preferably in default)?

Clari开发者_开发技巧fication: I want to an exception (preferably compiler error) occurs on some type usage / instantiation / member access. I want to prohobit a direct usage of EventLog in favour of TraceSource.


You can't get compile time error for classes loaded into an AppDomain since AppDomains are runtime concept. I don't know about run-tim way.

I would not recommned even trying to block usage of system classes like EventLog - you never know what other libraries use.

As an option you can do compile time check of your code to prohibit function calls (i.e. by using custom FXCop rule). You can also do similar check at run time for assemblies you are loading, also you will need to write more infrastructure to do so.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜