Hi all
I originally had a difficulty with authoring a .net control derived from System.Windows.Forms.UserControl. My problem came when attempting to use the authoured control on a web page. The control would instantiate perfectly happpily but would throw a security exception evertime I tried to do anything with DirectX.
Precise message was
The action that failed was:
Demand
The type of the first permission that failed was:
Microsoft.DirectX.Security.GraphicsPermission
Which was thrown in response to
Manager.CheckDeviceFormat(
Manager.Adapters.Default.Adapter,
DeviceType.Hardware,
Manager.Adapters.Default.CurrentDisplayMode.Format,
Usage.DepthStencil,
ResourceType.Surface,
DepthFormat.D16 )
Now then, this codes works perfectly well in a standalone .Net application but throws a graphics security exception when used in IE via codebase="http:MyDll.dll#namspace.class" etc.
What I managed to do is introduce the following line just above the CheckDeviceFormat call...
Microsoft.DirectX.Security.GraphicsPermission gp = new GraphicsPermission( System.Security.Permissions.PermissionState.Unrestricted );
gp.Assert();
This worked like a charm but is only half the story. In order to actually get a .Net dll control instantiated within IE you also have to use the [AllowPartiallyTurstedCallers], [System.Security.SuppressUnmanagedCodeSecurity] attributes, strong name sign it, trust it via the .Net framework wizard and add it to the assembly cache, sheesh !!
After jumping through all of these hoops you then find that you cannot script the control via JavaScript without adding your own custom interface and then adding the following line to your class
[Guid("D36A05BD-9410-426d-8F3A-4D9707D8790A"), ClassInterface(ClassInterfaceType.None), ComSourceInterfaces( typeof( ComClass1Events ) ) ]
Where ComClass1Events is your own custom event class.
It just all seems so very difficult !
My question to you chaps at Microsoft is how on earth do I deploy this to a machine which has never seen my dll because it sure doesn't work on anyone elses machine....
Alan Simes

DirectX 9, Internet Explorer and Security Exceptions
jason d
Managed DirectX is so close to the hardware that it inherantly allows unsafe things (e.g. take over the whole screen), and also has lots of unsafe code in it so its not something that should be run through a web page, where permission is granted through policies you would have to convince the user to set.
The only time I would reccomend this would be when you had to install to a fixed set of computers where you could install both the control and the .Net policy through an enterprise policy. For downloading over the net you are on your own.