Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / April 2007

Tip: Looking for answers? Try searching our database.

System.Security.SecurityException, EnumWindows & Callback

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Zamdrist - 06 Apr 2007 21:47 GMT
Running an application executable (release) runs find on my computer:

"The application attempted to perform an operation not allowed by the
security policy."...
System.Security.SecurityException:
System.Security.Permissions.SecurityPermission...

Thoughts?

I was able to narrow the problem down the EnumWindows API call and
AddressOf Callback routine here:

Public Sub InitList()
  Dim cb As CallBack
  cb = New CallBack(AddressOf MyCallBack)
  EnumWindows(cb, 0)
End Sub

Public Function MyCallBack(ByVal hwnd As IntPtr, ByVal lParam As
IntPtr) As Boolean

Dim intLen As Integer = GetWindowTextLength(hwnd) + 1

If intLen > 1 Then
Dim strText As New StringBuilder(intLen)

Try
GetWindowText(hwnd, strText, intLen)

If IsWindowEnabled(hwnd) And IsWindowVisible(hwnd) Then
   lvWindows.Items.Add(strText.ToString).SubItems.Add(hwnd.ToString)
End If

Catch ex As Exception
Trace.WriteLine(ex.ToString)
End Try

End If
Return True
End Function

Public Delegate Function CallBack(ByVal hwnd As IntPtr, ByVal lParam
As IntPtr) As Boolean
Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As
CallBack, ByVal lParam As Integer) As Integer
Brian - 08 Apr 2007 17:57 GMT
If you tried to execute it from a nework share/drive and that is what did
not work, try going to control panel->admin tools->.net framework config
1.1/2.0 etc.
Then adjust zone security. Adjust all the zones to allow everything and then
start backing them off again. This has worked for most everything I have
deployed although I was looking for answers myself because it doesn't work
on everything.

brian

> Running an application executable (release) runs find on my computer:
>
[quoted text clipped - 41 lines]
> Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As
> CallBack, ByVal lParam As Integer) As Integer
Zamdrist - 09 Apr 2007 15:19 GMT
> If you tried to execute it from a nework share/drive and that is what did
> not work, try going to control panel->admin tools->.net framework config
[quoted text clipped - 5 lines]
>
> brian

Thanks Brian.

What an absolute pain in the a.s programming has become. <sigh>

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.