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. .NET (Core and Framework)
  4. Recognizing an object instance after regenerating dinamicly the assembly

Recognizing an object instance after regenerating dinamicly the assembly

Scheduled Pinned Locked Moved .NET (Core and Framework)
dotnethelpquestionannouncement
1 Posts 1 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.
  • M Offline
    M Offline
    Mehdi_S
    wrote on last edited by
    #1

    Hi, I'm working on generating dynamically an assembly to let a user customize things. To do that, I used CSharpCodeProvider to generate the assembly and that worked fine till I encountered the problem of recognizing an instance created with the first version of the assembly after getting a second version. So here are the steps I followed: 1- I generated an assembly containing a class called "Class_1" which just has an attribute called "Name". 2- I created instance of that and added it to a set. For now, I can display all the item of the set (I used a main class Root which is created not dynamically and from which all the dynamic classes will inherit from). 3- I regenerated the assembly after adding "Class_2" which inherits from Root too and have a method that get as parameter a "Class_1" instance and that displays the name of the instance. 4- I created an instance of the second class and called its method with the "Class_1" instance that I created before. Doing that raised the following exception: Object of type 'TestProject_CustomClassesLibrary.Class_1' cannot be converted to type 'TestProject_CustomClassesLibrary.Class_1'. I searched on the net about that and I found multiple things: * Signing the assembly the GAC but when I tried it, nothing changed. * Using domain application but this require stopping the application each time we want to generate I guess (did not tried it by the way). So that's not a solution for me. Is there any solution for that? What should I do to make this work? Thanks for all.

    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