问题描述
您好, EnvDTE. Hi, EnvDTE. 表达 getPixelsAsPointer = applicationObject.Debugger.GetExpression( "pixelIntPtr" , true ,5); Expression getPixelsAsPointer = applicationObject.Debugger.GetExpression("pixelIntPtr", true,5); IntPtr pixPointer =( IntPtr ) 转换 .ToInt32 (getPixelsAsPointer.Value); IntPtr pixPointer = (IntPtr)Convert.ToInt32(getPixelsAsPointer.Value); 不安全 { byte * ptr =(byte *)pixPointer.ToPointer(); //在这里获取异常 byte* ptr=(byte*)pixPointer.ToPointer(); //Getting Exception Here for(int iIndex = 0; iIndex< height; iIndex ++) for (int iIndex = 0; iIndex < height; iIndex++) pixData [iIndex] = * ptr; pixData[iIndex] =*ptr; ptr = ptr + 1; ptr = ptr + 1; }} } } 这篇关于引用从Visual Studio文本编辑器传递的IntPtr在AddIN中引发异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
pixelIntPtr是引用字节数组的IntPtr.
IntPtr通过以下方式
pixelIntPtr is a IntPtr refering to a byte array.
I will get the IntPtr by the following way
{
{
我尝试遍历字节数组时遇到异常:AccessViolationException
尝试读取或写入受保护的内存.这通常表明其他内存已损坏.
我还想知道AddIn和Visual Studio文本编辑器是否处于同一进程中?
以及如何在AddIn中使用IntPtr?
请让我知道如何解决此问题.
Whetn i try to iterate through the byte array i am getting Exception:AccessViolationException
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
And i also want to know whether the AddIn and Visual Studio Text Editor are in same process?
And how to use IntPtr in AddIn?
Please let me know how to solve this issue.推荐答案