"Attempt to read or write protected memory"

Topics: Pre-release discussions
Jan 26, 2007 at 8:30 PM
Configuration:
VS2005 Professional
EntLib 3.0 January CTP

When I just try to edit app.config with "Edit Enterprise Library Configuration" I'm getting "Attempt to read or write protected memory. ..." message box which then kills the whole VS.
I tried the same after installing VS2005 SP1, having the same result.
The most amazing thing is that rarely, but it works!
The second amazement is that such "memory violation" happens in kind-of managed environment.

Any ideas?
What additional info is needed?
Jan 26, 2007 at 10:33 PM
I get a similar error once in awhile, too. Quitting Visual Studio and restarting "fixes" the problem.

It is intermittent and I haven't figured out the sequence of events causing it.

I will add it to the issue tracker as it should be at least flagged even though I can't repeat it on demand.

Regards,

Dave

__________________________

David Hayden
Microsoft MVP C#
Jan 30, 2007 at 2:48 PM
Restarting VS does not help (I have practically automatic "restart" because VS is just killed). I believe that PC reboot helps for a while.
Is there any additional info I can provide to tackle the problem?
For now I'm using standalone version of the editor, and it works perfectly well. This is an integration problem.
Jan 30, 2007 at 4:33 PM
David -

I ran into the same error when attempting to run Tom's strong naming guidance package against the EntLib v2 source. Restarting/rebooting did not solve the problem, and it is repeatable in my environment. Here's the stack trace:

Microsoft.Practices.RecipeFramework.ActionExecutionException: An exception occurred during the binding of reference or execution of recipe StrongNameSolution. Error was: Action StrongNameProjects failed to execute:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt..
You can remove the reference to this recipe through the Guidance Package Manager. ---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at EnvDTE80.Find2.Execute()
at Microsoft.Practices.EnterpriseLibrary.StrongNamingGuidancePackage.Actions.StrongNameProjectsAction.AddPublicKeyToInternalsVisible(List`1 projectList, String publicKey)
at Microsoft.Practices.EnterpriseLibrary.StrongNamingGuidancePackage.Actions.StrongNameProjectsAction.Execute()
at Microsoft.Practices.RecipeFramework.Recipe.Microsoft.Practices.RecipeFramework.Services.IActionExecutionService.Execute(String actionName, Dictionary`2 inputValues)
at Microsoft.Practices.RecipeFramework.Recipe.Microsoft.Practices.RecipeFramework.Services.IActionExecutionService.Execute(String actionName)
at Microsoft.Practices.RecipeFramework.Recipe.Microsoft.Practices.RecipeFramework.Services.IActionCoordinationService.Run(Dictionary`2 declaredActions, XmlElement coordinationData)
at Microsoft.Practices.RecipeFramework.Recipe.ExecuteActions(IDictionaryService readOnlyArguments, IDictionaryService arguments, ITypeResolutionService resolution)
--- End of inner exception stack trace ---
at Microsoft.Practices.RecipeFramework.Recipe.UndoExecutedActionsAndRethrow(Exception ex)
at Microsoft.Practices.RecipeFramework.Recipe.ExecuteActions(IDictionaryService readOnlyArguments, IDictionaryService arguments, ITypeResolutionService resolution)
at Microsoft.Practices.RecipeFramework.Recipe.Execute(Boolean allowSuspend)
at Microsoft.Practices.RecipeFramework.GuidancePackage.Execute(String recipe, IAssetReference reference, IDictionary arguments)
at Microsoft.Practices.RecipeFramework.GuidancePackage.Execute(IAssetReference reference)
at Microsoft.Practices.RecipeFramework.RecipeReference.OnExecute()
at Microsoft.Practices.RecipeFramework.AssetReference.Execute()
at Microsoft.Practices.RecipeFramework.PackageManagement.PackageManager.OnExecuteRecipe(Object sender, EventArgs e)

One caveat: Tom's blog on using his package against the v2 source said it "should" work, so this may just be a "it's not 100% polished code yet" bug.

Eric Hall
Jan 30, 2007 at 11:26 PM
Thanks for the reports everyone - we're looking into this. One question: can anyone confirm that this issue occurs when VS2005 SP1 is installed? Our very early non-scientific analysis seems to indicate that the issue may only occur when SP1 is not there, but we could be wrong.

Tom
Jan 31, 2007 at 1:40 PM
I have SP1 installed and get the problem intermittently.

Regards,

Dave

________________________

David Hayden
Microsoft MVP C#
Jan 31, 2007 at 3:04 PM
Edited Jan 31, 2007 at 3:05 PM

tomhollander wrote:
Thanks for the reports everyone - we're looking into this. One question: can anyone confirm that this issue occurs when VS2005 SP1 is installed? Our very early non-scientific analysis seems to indicate that the issue may only occur when SP1 is not there, but we could be wrong.

Tom

Yes, I had it on both original version and after installation of SP1.

Thanks,
Victor
Jan 31, 2007 at 6:40 PM
I've found quite a few such error sequences in my Application Log:

----------------------------------------
Event Type: Error
Event Source: Microsoft Visual Studio
Event Category: None
Event ID: 1000
Date: 1/31/2007
Time: 1:57:59 PM
User: N/A
Computer: VICTOR
Description:
Faulting application devenv.exe, version 8.0.50727.762, stamp 45716759, faulting module kernel32.dll, version 5.1.2600.2945, stamp 44ab9a84, debug? 0, fault address 0x00012a5b.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Data:
0000: 41 00 70 00 70 00 6c 00 A.p.p.l.
0008: 69 00 63 00 61 00 74 00 i.c.a.t.
0010: 69 00 6f 00 6e 00 20 00 i.o.n. .
0018: 46 00 61 00 69 00 6c 00 F.a.i.l.
0020: 75 00 72 00 65 00 20 00 u.r.e. .
0028: 20 00 64 00 65 00 76 00 .d.e.v.
0030: 65 00 6e 00 76 00 2e 00 e.n.v...
0038: 65 00 78 00 65 00 20 00 e.x.e. .
0040: 38 00 2e 00 30 00 2e 00 8...0...
0048: 35 00 30 00 37 00 32 00 5.0.7.2.
0050: 37 00 2e 00 37 00 36 00 7...7.6.
0058: 32 00 20 00 34 00 35 00 2. .4.5.
0060: 37 00 31 00 36 00 37 00 7.1.6.7.
0068: 35 00 39 00 20 00 69 00 5.9. .i.
0070: 6e 00 20 00 6b 00 65 00 n. .k.e.
0078: 72 00 6e 00 65 00 6c 00 r.n.e.l.
0080: 33 00 32 00 2e 00 64 00 3.2...d.
0088: 6c 00 6c 00 20 00 35 00 l.l. .5.
0090: 2e 00 31 00 2e 00 32 00 ..1...2.
0098: 36 00 30 00 30 00 2e 00 6.0.0...
00a0: 32 00 39 00 34 00 35 00 2.9.4.5.
00a8: 20 00 34 00 34 00 61 00 .4.4.a.
00b0: 62 00 39 00 61 00 38 00 b.9.a.8.
00b8: 34 00 20 00 66 00 44 00 4. .f.D.
00c0: 65 00 62 00 75 00 67 00 e.b.u.g.
00c8: 20 00 30 00 20 00 61 00 .0. .a.
00d0: 74 00 20 00 6f 00 66 00 t. .o.f.
00d8: 66 00 73 00 65 00 74 00 f.s.e.t.
00e0: 20 00 30 00 30 00 30 00 .0.0.0.
00e8: 31 00 32 00 61 00 35 00 1.2.a.5.
00f0: 62 00 0d 00 0a 00 b.....

----------------------------------------
Event Type: Error
Event Source: .NET Runtime
Event Category: None
Event ID: 1023
Date: 1/31/2007
Time: 1:58:05 PM
User: N/A
Computer: VICTOR
Description:
.NET Runtime version 2.0.50727.42 - Fatal Execution Engine Error (7A2B45A2) (0)

Maybe this will help a little in troubleshooting?

Victor
Feb 1, 2007 at 1:05 AM
Edited Feb 1, 2007 at 1:08 AM
Thanks Victor - any additional information helps. Actually if you or anyone else see this crash, it would be an enormous help if you could post or mail (tomholl at microsoft.com) as much detail as possible, such as:
- OS
- VS edition + service pack
- Any unusual plug-ins or extensions (eg GAX, WF designers, WPF designers)
- What you were doing when the error occurred
- The text of the error you received, and whether it crashed VS or not
- Any event log entries

Also if it looks like the problem occurs with certain config files and not others, it would be great if you could send the file (although it may have nothing to do with this).

We appreciate your help here - as I'm sure most of you know, diagnosing bugs that can't be reliably reproduced is pretty painful.

Thanks!
Tom
Feb 1, 2007 at 8:38 PM
Edited Feb 1, 2007 at 8:51 PM
I solved the problem (for myself at least):

1. I had EntLib 2.0 January 2006. Uninstalled it.
2. Uninstall EntLib 3.0 January 2007
3. Delete registry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\Packages\{488366a4-630c-4a0e-a6a2-b019cee13bea}
4. Install EntLib 3.0 January 2007
5. Remove all EntLib-related strong naming from app.config and web.config in my projects.

Results:
1. "Edit Enterprise Library Configuration" in VS2005 works fine for my own projects.
My projects use EntLib from "C:\Program Files\Microsoft Enterprise Library 3.0 - January 2007 CTP\Bin"
After saving, all strong names in app.config (which I have removed) are restored.

2. My "standalone" C:\EntLib3Src EntLib was rebuild and has version 2.9.9.1.
Attempt to "Edit Enterprise Library Configuration" in VS2005 for QuickStart samples from C:\EntLib3Src gives "Attempt to read or write protected memory. ..." message box, but with advice to re-install EntLib, and does not kill VS2005 any more.
Though further attempts to "Edit Enterprise Library Configuration" even for my own projects failes with the same message.
Restart VS2005 helps to get rid of it.

Smells like "DLL Hell" to me.

Regards,
Victor
Mar 30, 2007 at 1:12 PM
VikVik, I tried the steps 1-4 (except that I used February Beta CTP).
It still crashes on my projects and on the EntLib samples (i.e. Cryptography sample). Only now it shows a standard "Visual studio encountered problem ..." dialog and provides minidumps/etc.
Before it was just "Attempt to read or write protected memory. ..." message - no minidumps whatsoever.
Mar 30, 2007 at 2:35 PM
There are known problems with the Feb 2007 CTP VS-Integrated Configuration Editor, so my recommendation is to just avoid it.

Tom mentioned they fixed a lot of the problems after the Feb 2007 CTP, so the release version should not have these problems. Ent Lib 3.0 should be released any day now.

Regards,

Dave

____________________________

David Hayden
Microsoft MVP C#