1

My windows application using user control and one dll is loaded on 4 pc. One of the pcs pop up , "Attempted to read/write protected memory". Pls give me advise.

Windows form is just used as back ground. User control is loaded on this win form and add one dll in the reference.

TNA
  • 616
  • 1
  • 9
  • 25

3 Answers3

4

I don't think this has anything to do with user permissions, as others have said.

I've experienced this before when working with unsafe pointers in C#. This is the error you get when you try to write on another program's memory.

What you might try doing (besides deploying a debug build to your test machines) is to turn ON the AccessViolationException from within the Visual Studio. You can do this by going Debug > Exceptions > Common Language Runtime Exceptions > System. Check the checkbox next to System.AccessViolationException. If you're lucky, you'll see where the error is occurring.

Edit:

Additionally, I've found this older post where another poster has a similar issue: Attempted to read or write protected memory

Community
  • 1
  • 1
Charlie Salts
  • 13,109
  • 7
  • 49
  • 78
  • Useful tip (turning on break on AccessViolationException) +1 – krebstar Nov 23 '09 at 05:45
  • Hi, I don't know whether it's reaalted or not. What I left to tell is I also use this dll in my other C# win form which is not using usercontrol. But this api is working fine. So, I changed the whole user control to window form.Since that time,this problem never happened again. I still cannot figure out why. – TNA Jul 28 '10 at 14:03
  • It sounds like your user control was doing something incorrectly. What was the purpose of the user control?I'm glad the problem does not happen anymore, but if I were you, I'd still want to know the cause :) – Charlie Salts Jul 28 '10 at 21:23
1

I was getting the exact same message in an application, and it was very hard to get it solved. I have googled for that message and have found a number of different causes and solutions.... none of them worked for me.

Well, in my case, I was using a COM object in my .NET application.... and that error would appear randomly in different parts of the code. Eventually, after lot of time debbugging, I found that the following line was causing the error:

arr = doc.GetAllExternalReferences3(objOptions, objRefVar, objIsVirtual)

objRef and objIsVirtual were byref parameters. I am not an Interop expert, but it seems that casting from the original types (in COM) to "object" in .NET was not working very well, specially when the scope of those objects finished. Anyway, I didn't need those values and there was an overloaded method that didn't need those parameters. So I was lucky and didn't need to go deep into the COM interop details. Anyway, I learned that one has to be very carefull with what a COM objects return to .NET....

Not sure if this is the case for you. But perhaps this anwer can help anyone else googling for this message.

Sam
  • 348
  • 2
  • 10
0

Without much to go on are the user permissions different on the one pc?

Kevin LaBranche
  • 20,908
  • 5
  • 52
  • 76