引用从Visual Studio文本编辑器传递的IntPtr在AddIN中引发异常 [英] Refering a IntPtr passed from Visual Studio Text Editor is throwing Exception in AddIN

查看:102
本文介绍了引用从Visual Studio文本编辑器传递的IntPtr在AddIN中引发异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

EnvDTE.

Hi,
    

EnvDTE.

表达 getPixelsAsPointer = applicationObject.Debugger.GetExpression( ,5);

Expression getPixelsAsPointer = applicationObject.Debugger.GetExpression("pixelIntPtr", true,5);
pixelIntPtr is a IntPtr refering to a byte array.

I will get the IntPtr by the following way

 

IntPtr pixPointer =( ) 转换

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;

}}

}

我尝试遍历字节数组时遇到异常: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.

推荐答案



有人知道如何解决这个问题.
请让我知道上面的代码有什么问题.
和问候.
Hi,

Does anyone knows how to solve this .
Please let me know is anything wrong in the above code.
Thanks and Regards.


这篇关于引用从Visual Studio文本编辑器传递的IntPtr在AddIN中引发异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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