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. Web Development
  3. ASP.NET
  4. Error - can not create enum dynamically

Error - can not create enum dynamically

Scheduled Pinned Locked Moved ASP.NET
help
3 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.
  • U Offline
    U Offline
    unil Dhiman
    wrote on last edited by
    #1

    Hi All, I am trying to create Enum Dynamically. When I try to Save dll It gives me error - "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))" I am also writing code snippet :- AppDomain currentDomain = AppDomain.CurrentDomain; AssemblyName aName = new AssemblyName("TempAssembly"); AssemblyBuilder ab = currentDomain.DefineDynamicAssembly(aName, AssemblyBuilderAccess.RunAndSave); ModuleBuilder mb = ab.DefineDynamicModule(aName.Name, aName.Name + ".dll"); EnumBuilder eb = mb.DefineEnum("Elevation", TypeAttributes.Public, typeof(int)); eb.DefineLiteral("Low", 0); eb.DefineLiteral("High", 1); Type finished = eb.CreateType(); ab.Save(aName.Name + ".dll"); I got error at last line. Please help me. your help is appreciated. Regards, Sunil Dhiman

    A A 2 Replies Last reply
    0
    • U unil Dhiman

      Hi All, I am trying to create Enum Dynamically. When I try to Save dll It gives me error - "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))" I am also writing code snippet :- AppDomain currentDomain = AppDomain.CurrentDomain; AssemblyName aName = new AssemblyName("TempAssembly"); AssemblyBuilder ab = currentDomain.DefineDynamicAssembly(aName, AssemblyBuilderAccess.RunAndSave); ModuleBuilder mb = ab.DefineDynamicModule(aName.Name, aName.Name + ".dll"); EnumBuilder eb = mb.DefineEnum("Elevation", TypeAttributes.Public, typeof(int)); eb.DefineLiteral("Low", 0); eb.DefineLiteral("High", 1); Type finished = eb.CreateType(); ab.Save(aName.Name + ".dll"); I got error at last line. Please help me. your help is appreciated. Regards, Sunil Dhiman

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      Is it your web application ? if yes then where the application is hosted ? Do you have the write permission on that dll ?

      Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

      1 Reply Last reply
      0
      • U unil Dhiman

        Hi All, I am trying to create Enum Dynamically. When I try to Save dll It gives me error - "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))" I am also writing code snippet :- AppDomain currentDomain = AppDomain.CurrentDomain; AssemblyName aName = new AssemblyName("TempAssembly"); AssemblyBuilder ab = currentDomain.DefineDynamicAssembly(aName, AssemblyBuilderAccess.RunAndSave); ModuleBuilder mb = ab.DefineDynamicModule(aName.Name, aName.Name + ".dll"); EnumBuilder eb = mb.DefineEnum("Elevation", TypeAttributes.Public, typeof(int)); eb.DefineLiteral("Low", 0); eb.DefineLiteral("High", 1); Type finished = eb.CreateType(); ab.Save(aName.Name + ".dll"); I got error at last line. Please help me. your help is appreciated. Regards, Sunil Dhiman

        A Offline
        A Offline
        Abhishek Sur
        wrote on last edited by
        #3

        The code seems to be fine. It should work. The problem definitely is the FileIOPermission. Check if ASP.NET has write permission to the folder where the dll is created. :(

        Abhishek Sur


        My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

        **Don't forget to click "Good Answer" if you like to.

        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