是类NativeMethods在.NET特殊处理? [英] Is the class NativeMethods handled specially in .NET?

查看:2104
本文介绍了是类NativeMethods在.NET特殊处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://msdn.microsoft.com/ EN-US /库/ ms182161%28VS.80%29.aspx

都在此介绍的三类分页特别是在.NET框架处理? (NativeMethods,SafeNativeMethods和UnsafeNativeMethods)

我问的是我想知道,如果它是好的创建NativeMethods类类别的原因。例如:

  ComNativeMethods
User32NativeMethods
OleStorageNativeMethods
 

解决方案

这是一个惯例,并不是必需的。如果反映到CLR和看看code。在那里,你会经常看到NativeMethods类中的P / Invoke code。我相信的FxCop将建议把你的P / Invoke code中的一类像这样如果遇到它。

http://msdn.microsoft.com/en-us/library/ms182161%28VS.80%29.aspx

Are the three classes described on this paged handled specially in the .NET Framework? (NativeMethods, SafeNativeMethods and UnsafeNativeMethods)

The reason I'm asking is I'm wondering if it is alright to create categories of NativeMethods classes. For example:

ComNativeMethods
User32NativeMethods
OleStorageNativeMethods

解决方案

It's a convention, not a requirement. If you reflect into the CLR and take a look at code in there, you'll often see P/Invoke code inside a NativeMethods class. I believe that FxCop will recommend putting your P/Invoke code in a class like this if it encounters it.

这篇关于是类NativeMethods在.NET特殊处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆