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 / Windows Forms / WinForm General / August 2005

Tip: Looking for answers? Try searching our database.

DragDrop registration failed in IE hosted control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Will Holley - 30 Aug 2005 11:07 GMT
Hi,

We have written a simple user control which we are hosting in IE which
allows users to upload files by browsing or drag / droping files onto it. We
have done a fair amount of work before with hosted controls in IE and have an
MSI which is installed for all users which gives Full Trust to all our
controls.

However, when the control is loaded we get an exception

System.InvalidOperationException: DragDrop registration failed. --->
System.Security.SecurityException: Request for the permission of type
System.Security.Permissions.UIPermission, mscorlib, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
  at System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet
grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
PermissionToken permToken)
  at System.Security.CodeAccessSecurityEngine.Check(PermissionToken
permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32
checkFrames, Int32 unrestrictedOverride)
  at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission
cap, StackCrawlMark& stackMark)
  at System.Security.CodeAccessPermission.Demand()
  at System.Windows.Forms.Control.SetAcceptDrops(Boolean accept)
  --- End of inner exception stack trace ---
  at System.Windows.Forms.Control.SetAcceptDrops(Boolean accept)
  at System.Windows.Forms.Control.OnHandleCreated(EventArgs e)
  at Microsoft.Ink.InkPicture.OnHandleCreated(EventArgs e)
  at System.Windows.Forms.Control.WmCreate(Message& m)
  at System.Windows.Forms.Control.WndProc(Message& m)
  at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
  at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
  at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

However, when attaching the debugger to IE, this exception is not thrown
until AFTER the code which registers the drag drop events has appeared to run
successfully. I.e. I can set happily through the constructor and the
AllowDrop = true statement with no exception being thrown. The exception
happens after I step out of our code and there is no trace back to our code.

I have made sure that any calls to AllowDrop and references to the drag drop
events / handlers are all asserting UIPermission.

On searching newsgroups it seems some people have had issues like this
resolved by fixing their application to a single thread by calling:

System.Threading.Thread.CurrentThread.ApartmentState =
System.Threading.ApartmentState.STA;

this seems to have no effect for us and I think it may call wierdness in IE.
Any suggestions would be very gratefully recieved!
Will Holley - 30 Aug 2005 12:46 GMT
Ok problem solved - I was being dumb. All that was required was to override
the OnHandleCreated method from InkPicture with:

protected override void OnHandleCreated(EventArgs e)
{
new UIPermission(PermissionState.Unrestricted).Assert();
base.OnHandleCreated (e);
CodeAccessPermission.RevertAssert();
}

> Hi,
>
[quoted text clipped - 48 lines]
> this seems to have no effect for us and I think it may call wierdness in IE.
> Any suggestions would be very gratefully recieved!

Rate this thread:







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.