We help IT Professionals succeed at work.

how to avoid security exceptions in c# when calling unmanaged dlls

Ikelca
Ikelca asked
on
please see attached image
i have this error in some computers, but not others.
how do i fix this??

it's from my program (a little utility programmed with c#), it requires .net framework 2.0 error
Comment
Watch Question

Software Consultant
CERTIFIED EXPERT
Commented:
check below link there is security tutorial for unmanaged code.

http://msdn.microsoft.com/en-us/library/aa288469(v=vs.71).aspx
Is your program trying to access a network? You can probably take a look at .net configuration wizard and try adjusting the security policy.

Author

Commented:
actually, im trying to run this little program from network

Author

Commented:
i dont understand how come this security exception happens to some machine not all machines.
all the machines are identical.
CERTIFIED EXPERT
Top Expert 2016
Commented:
the message box comes from printer utility. so if not all computers use the same printer the difference is because of different printer installation/drivers.

i would say the dll tries to reset printer defaults at exit and demands for access rights. so if that works at other computers either the defaults (or current state) are ok for them or they have different policy regarding their printers.

did you try to use JIT (just-in-time) debugger as suggested in the message?

Sara

Author

Commented:
no, the machines which had this problem don't have JIT debugger.
but I followed what you guys told me and it seems ok after i put [SuppressUnmanagedCodeSecurity()]
in my code and i tried with .net configuration tool as well, it worked.
thank you all

Explore More ContentExplore courses, solutions, and other research materials related to this topic.