Re: Graphics.GetHdc causes InvalidOperationException

From: Nicole Calinoiu (calinoiu)
Date: 06/29/05

  • Next message: Rob R. Ainscough: "SSL certificates -- how are they validated?"
    Date: Wed, 29 Jun 2005 13:45:27 -0400
    
    

    "Richard Morris" <khiron@community.nospam> wrote in message
    news:esWHh18eFHA.688@TK2MSFTNGP14.phx.gbl...
    > Hi Nicole,
    >
    > Thanks for answering. The problem is that assigning Full Trust to
    > assemblies with MS strongkey is not enough. Is it possible that some
    > assemblies which come from MS aren't signed with their key?

    The strong names of Microsoft assemblies are irrelevent here. The problem
    is that your control assembly does not have SecurityPermission\UnmanagedCode
    on the client machine.

    > protected override void OnPaint(PaintEventArgs e) {
    > // serurity exception
    > IntPtr hdc = e.Graphics.GetHdc();
    > e.Graphics.ReleaseHdc(hdc);

    Since you're not actually using the GDI device context, I'm wondering why
    you're bothering with this. If it's just an incomplete sample, and you
    actually need to use unmanaged GDI functions, then you'll need to set up the
    client to grant SecurityPermission\UnmanagedCode to your assembly (which it
    will also need for the actual GDI calls). Otherwise, you should be able to
    get the method to work by dropping the above two lines.

    > Would you like to take a closer look at this scenario? I could send you a
    > sample project and screenshots showing the problem.

    Not necessary. I was able to repro based on your sample code.


  • Next message: Rob R. Ainscough: "SSL certificates -- how are they validated?"

    Relevant Pages

    • Re: Difference between Assembly and Module?
      ... > A module is the code generated from a single file. ... > Visual Studio is to compile all the files and make an assembly containing ... You can however create assemblies ... > Answer those GDI+ questions with the GDI+ FAQ ...
      (microsoft.public.dotnet.languages.csharp)
    • Re: Difference between Assembly and Module?
      ... A module is the code generated from a single file. ... Classes, or modules, are distributed in Assemblies along with other embedded ... The default method for creating an executable file, either EXE or DLL from ... Answer those GDI+ questions with the GDI+ FAQ ...
      (microsoft.public.dotnet.languages.csharp)
    • Re: Strange error for referencing dll
      ... The assemblies in that folder are also duplicated in the GAC. ... Answer those GDI+ questions with the GDI+ FAQ ...
      (microsoft.public.dotnet.languages.vb)
    • Re: How to register .NET Dlls
      ... you can register them in the GAC. ... >> have sign your assemblies (dlls), using key generated by sn.exe tool. ... >> Then in the client machine you perfrm gacutil -i your.dll. ...
      (microsoft.public.dotnet.general)
    • Re: Gacutil.exe for dotnet 2.0 ?
      ... It won't be present on the client machine. ... Either install the assembly using a setup project, send gacutil.exe along with your project (or install the entire SDK), or manually add the assembly by dropping the file in C:\Windows\Assembly ... Also when i wanted to register the assemblies during the install time in a ...
      (microsoft.public.dotnet.general)