Jonathan.Peppers

This error occurs when I use the Resources File (.resx) designer. I use png files as resources throughout my application, and every other time I click "Add Existing File..." and choose a png file, I get:

"Attempted to read or write protected memory. This is an indication that other memory is corrupt."

Which is in a message box. The image (.png) file then isn't added.

However, if I do the exact same thing a second time, it works correctly and add the file, but my Intellisense doesn't work until I close VS and open it again.

This is a rather annoying error. Here's some info about my PC that might matter:

-Windows XP

-VS 2005 SP2, I believe

-.Net 2.0, 3.0, 3.5 beta, 2.0 cf SP2 installed

-Dual Core Processor

-Windows SDK installed

-Windows Mobile 5.0 & 6.0 SDKs installed

-DirectX SDK installed

This was happening well before I installed 3.0 and 3.5, I've just been too lazy to post about this. What is going on here



Re: Visual C# IDE Attempted to read or write protected Memory.

Karthikeya Pavan Kumar .B

check this link




Re: Visual C# IDE Attempted to read or write protected Memory.

Jonathan.Peppers

I've read that post and already tried that, but thanks anyways.

The error doesn't happen while running my code, just while using VS 2005.

Any other ideas I'd hate to reinstall VS, I have like fifty add-ons and sdks installed and I don't want to redo that.





Re: Visual C# IDE Attempted to read or write protected Memory.

Figo Fei - MSFT

Hi, Jonathan

If we create a new project, do we have the problem Sometimes corrupted project settings can cause problems. These are project specific.

Try to reset the settings in VS2005: menu Tools >> Import and Outport settings >> Reset all settings (please export your recent settings for backup)

After these, if the issue is still alive.

You can do the following steps to deal with the case:
1. Reboot the machine into Safe Mode. Do we still have the problem This can isolate some third party application/driver¡¯s interference.(In addition to safe mode, we also suggest ¡°clean boot¡±: http://support.microsoft.com/kb/310353.)
2. If we switch to try a new user account, do we have the problem This can rule out the possibility of corrupted user profile.
3. Do we have any third party add-ins loaded Disable them with ¡°Tools¡± | ¡°Add-in Manager¡­¡±.

If the problem persist, please check whether the sp1 for Visual Studio is applied .

Thanks






Re: Visual C# IDE Attempted to read or write protected Memory.

Figo Fei - MSFT

Jonathan.Peppers wrote:

-Windows XP

-VS 2005 SP2, I believe

-.Net 2.0, 3.0, 3.5 beta, 2.0 cf SP2 installed

-Dual Core Processor

-Windows SDK installed

-Windows Mobile 5.0 & 6.0 SDKs installed

-DirectX SDK installed

This was happening well before I installed 3.0 and 3.5, I've just been too lazy to post about this. What is going on here

As far as I know, only sp1 for VS 2005 released. Never see sp2 for it.

Thanks






Re: Visual C# IDE Attempted to read or write protected Memory.

Jonathan.Peppers

That's what I meant, I just remember installing a service pack and I didn't look it up.

Jeez, so I guess calling VS 2005 SP1, VS 2005 SP2 is to a Microsoft guy like calling Will Shatner, Spock for a star trek nerd.





Re: Visual C# IDE Attempted to read or write protected Memory.

Jonathan.Peppers

Well, I figured out the bug...

I was saving Pngs from Photoshop into the Resources directory of my project, and then adding the images to the resources file directly from there.

Normally, you would add pictures from a different directory and VS 2005 would copy them to the resources directory for you.

This error's seems as simple as calling File.Exists or setting File.Copy to overwrite, but maybe there is something more complicated going on than I fully understand.

Maybe you Microsoft guys can enlighten us on why this happens, surely I'm not the only one that has every experienced this problem.

Oh and thanks for helping me out so much by the way, I think got one whole relevant post on my issue, and another was an annoying correction of me mistakeningly typing SP2 rather than SP1.





Re: Visual C# IDE Attempted to read or write protected Memory.

Figo Fei - MSFT

Hi, Jonathan

I guess the cause could be the picture is in using with the photoShop or something.

We can manually copy the file to the resources folders under the project, and again add it into our project.(although it is duplicate job)

You could try to cope another clean file for testing, VS will work with these actions.

Thanks






Re: Visual C# IDE Attempted to read or write protected Memory.

Jonathan.Peppers

I'm hitting Save For Web in photoshop which creates a duplicate, optimized image of the PSD. So I don't believe it's going to still hold file access on the image.

Additionally, if I close photshop entirely, VS gives the error. The above mentioned error happens on my machine no matter where the picture came from.

If I place an image in my Resources folder and then add it to the .resx file, I get the error.





Re: Visual C# IDE Attempted to read or write protected Memory.

Figo Fei - MSFT

Hi, Jonathan

It seems to work well on my side.

Could you give the steps to reproduce the problem and what version of Visual Studio are you using

Thanks






Re: Visual C# IDE Attempted to read or write protected Memory.

Jonathan.Peppers

If I click on About, and click Copy Info I get:

Microsoft Visual Studio 2005
Version 8.0.50727.363 (SP.050727-3600)
Microsoft .NET Framework
Version 2.0.50727

Installed Edition: Professional

Microsoft Visual Basic 2005 77626-009-1251921-41329
Microsoft Visual Basic 2005

Microsoft Visual C# 2005 77626-009-1251921-41329
Microsoft Visual C# 2005

Microsoft Visual C++ 2005 77626-009-1251921-41329
Microsoft Visual C++ 2005

Microsoft Visual J# 2005 77626-009-1251921-41329
Microsoft Visual J# 2005

Microsoft Visual Web Developer 2005 77626-009-1251921-41329
Microsoft Visual Web Developer 2005

Microsoft Web Application Projects 2005 77626-009-1251921-41329
Microsoft Web Application Projects 2005
Version 8.0.50727.363

Crystal Reports AAC60-G0CSA4B-V7000AY
Crystal Reports for Visual Studio 2005


Extensions for Windows WF
Windows Workflow Foundation Tools for Visual Studio

Microsoft Visual Studio 2005 Professional Edition - ENU Service Pack 1 (KB918525)
This service pack is for Microsoft Visual Studio 2005 Professional Edition - ENU. \n
If you later install a more recent service pack, this service pack will be uninstalled automatically. \n
For more information, visit http://support.microsoft.com/kb/918525

Orcas Technology Preview - .NET Framework 3.0 Development Tools 1.0
Microsoft Visual Studio Code Name Orcas Community Technology Preview - Development Tools for WinFX

SlickEdit Gadgets 1.0 SlickEdit Gadgets
Installed Packages: CommandSpy , Editor Gadgets , SLOC Graph , IDataObject Analyzer , File Explorer
Version: 1.0.0.90
Build date: 12/28/2006 16:36

I supposedly installed SP1 for VS 2005, but it doesn't seem to show up here. SlickEdit shows up, but this error was happening before I installed it.





Re: Visual C# IDE Attempted to read or write protected Memory.

Jonathan.Peppers

Sorry forgot the steps:

  1. Create any project.
  2. Click add new item (.resx) Resources file
  3. Add any picture to the .resx file (this will create the Resources directory)
  4. Place a .png file in the the Resources directory
  5. Add the .png to the Resources file

Note: you may have to repeat #5 more than once for it to happen, but it seems to happen 75% of the time on my machine.