Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Change ClassName in c#

Change ClassName in c#

Scheduled Pinned Locked Moved C#
csharphelpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RYU
    wrote on last edited by
    #1

    Hi, If I built a windows application in VS2008, the class name I got is something like WindowsForms10.Window.8.app.0.378734a Is it possible to change this class name? I tried to do

    protected override System.Windows.Forms.CreateParams CreateParams
    {
        [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
        get
        {
            System.Windows.Forms.CreateParams cp = base.CreateParams;
            cp.ClassName = "MyTestApp.MainForm";
            return cp;
        }
    }
    

    But every time I run my application, I got this error

    Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.

    Any idea? Cheers :)

    L 1 Reply Last reply
    0
    • R RYU

      Hi, If I built a windows application in VS2008, the class name I got is something like WindowsForms10.Window.8.app.0.378734a Is it possible to change this class name? I tried to do

      protected override System.Windows.Forms.CreateParams CreateParams
      {
          [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
          get
          {
              System.Windows.Forms.CreateParams cp = base.CreateParams;
              cp.ClassName = "MyTestApp.MainForm";
              return cp;
          }
      }
      

      But every time I run my application, I got this error

      Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.

      Any idea? Cheers :)

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      RYU^^ wrote:

      Any idea?

      Why on earth would you want to do such a thing?

      xacc.ide - now with TabsToSpaces support
      IronScheme - 1.0 alpha 4a out now (29 May 2008)
      ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))

      R 1 Reply Last reply
      0
      • L leppie

        RYU^^ wrote:

        Any idea?

        Why on earth would you want to do such a thing?

        xacc.ide - now with TabsToSpaces support
        IronScheme - 1.0 alpha 4a out now (29 May 2008)
        ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))

        R Offline
        R Offline
        RYU
        wrote on last edited by
        #3

        leppie wrote:

        Why on earth would you want to do such a thing?

        Do you mean changing the class name from WindowsForms10.Window.8.app.0.378734a to MyTestApp.MainForm? Well, I need to do that so that I can use FindWindow(). The reason I need to use FindWindow() is because that is the only function I can find in NSIS (NULLSoft) to find out whether specific application is running or not. Cheers :)

        D 1 Reply Last reply
        0
        • R RYU

          leppie wrote:

          Why on earth would you want to do such a thing?

          Do you mean changing the class name from WindowsForms10.Window.8.app.0.378734a to MyTestApp.MainForm? Well, I need to do that so that I can use FindWindow(). The reason I need to use FindWindow() is because that is the only function I can find in NSIS (NULLSoft) to find out whether specific application is running or not. Cheers :)

          D Offline
          D Offline
          DrWatsonCoding
          wrote on last edited by
          #4

          You must use RegisterClassEx first.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups