Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6831813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:46:56+00:00 2026-05-26T22:46:56+00:00

I have a code like this public static Type ToType(XmlSerializableType xmlSerializableType) { string func

  • 0

I have a code like this

public static Type ToType(XmlSerializableType xmlSerializableType)
{
  string func = "XmlSerialzationType.ToType";
  Type type = null;
  if (xmlSerializableType != null && xmlSerializableType.Name != string.Empty)
  {
    type = Type.GetType(xmlSerializableType.Name);
    if (type == null)
    {
      // May be a user defined class
      try
      {
        Assembly assembly = Assembly.Load(xmlSerializableType.AssemblyName);
        type = assembly.GetType(xmlSerializableType.Name);
      }
      catch (Exception ex)
      {
        TestDebug.DebugTraceSevere(func, "Exception " + ex.ToString());
      }
    }
  }
  return type;
}

I have a base class named “leaf” and a userdefinedclass named “roundedtree”
when ‘xmlSerializableType.Name‘ becomes userdefined class ‘_rounded_tree’, first time i am getting value for ‘assembly as _rounded_treeGOLD, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' and so for ‘type as {Name = “_rounded_tree” FullName = “_rounded_tree”}’. But after saving if i restart my application i cannot load value for ‘assembly’ getting exception ‘Could not load file or assembly ‘_rounded_treeGOLD, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. The system cannot find the file specified.”:”_rounded_treeGOLD, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null‘ and return type becomes null this should not happen

For baseclass “leaf” no issuses i will get xmlSerializableType.Name as ” Root.Systemmodel.leaf” and ‘type’ becomes {Name = “leaf” FullName = “Root.Systemmodel.leaf”} assembly will be Root.Systemmodel, Version=8.0.7.0, Culture=neutral, PublicKeyToken=83bd062a94e26d58
What should i do in these circumstances
This is a bit of code which will generate assembly for userdefined class

public Type CreateType()
      {
         string func = "ManagedClass.CreateType";

         // Create instances of AssemblyBuilder and ModuleBuilder for the new Type
         AppDomain myDomain = Thread.GetDomain();
         AssemblyName myAsmName = new AssemblyName();

         // Create the assembly name by appending the machine name to the typename.
         myAsmName.Name = this.TypeName + Environment.MachineName;
         // Define assembly that can be executed but not saved
         this.UserClassAssemblyBuilder = myDomain.DefineDynamicAssembly(myAsmName, AssemblyBuilderAccess.Run);
         // Create dynamic module with symbol information
         this.UserClassModuleBuilder = this.UserClassAssemblyBuilder.DefineDynamicModule("userdefinedmodule", true);

UPDATE

probably my assembly is creating for userdefined class but not saving that may be the reason i am not facing any issue first time, once i close the application i will lose that one see my code

// Define assembly that can be executed but not saved
         this.UserClassAssemblyBuilder = myDomain.DefineDynamicAssembly(myAsmName,

AssemblyBuilderAccess.Run);
how to overcome this situation

UPDATE
Here my database is xml files. When i checked for base class leaf i can see the entry is <Name>Root.Systemmodel.WindowsSystem</Name><AssemblyName>Root.Systemmodel, Version=8.0.7.0, Culture=neutral, PublicKeyToken=83bd062a94e26d58</AssemblyName> in this case if restart my application no issues, but for user defined class “roundedtree” xml entry is <Name>_rounded_tree</Name> <AssemblyName>_rounded_treeGOLD, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</AssemblyName>
Here first time no issues, but if i restart my application i am getting exception

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:46:56+00:00Added an answer on May 26, 2026 at 10:46 pm

    it happens because maybe the assembly you’re going to load references to the another assembly that not exist in the same directory or system directory put all assembly in same folder
    I,ve just copy paste my code but its clear

    private string asmBase;
    public Type[] GetAllTypeinAssembly(string assemblyName)
    {
        asmBase = System.IO.Path.GetDirectoryName(assemblyName);
    
        AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
        System.Reflection.Assembly asm = System.Reflection.Assembly.Load(System.IO.File.ReadAllBytes(assemblyName));//domain.Load(bt) ;// 
    
        return asm.GetTypes();
    }
    
    
    private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
    {
        //This handler is called only when the common language runtime tries to bind to the assembly and fails.
    
        //Retrieve the list of referenced assemblies in an array of AssemblyName.
        Assembly MyAssembly, objExecutingAssemblies;
        string strTempAssmbPath = "";
        objExecutingAssemblies = args.RequestingAssembly;
        AssemblyName[] arrReferencedAssmbNames = objExecutingAssemblies.GetReferencedAssemblies();
    
        //Loop through the array of referenced assembly names.
        foreach (AssemblyName strAssmbName in arrReferencedAssmbNames)
        {
            //Check for the assembly names that have raised the "AssemblyResolve" event.
            if (strAssmbName.FullName.Substring(0, strAssmbName.FullName.IndexOf(",")) == args.Name.Substring(0, args.Name.IndexOf(",")))
            {
                //Build the path of the assembly from where it has to be loaded.                
                strTempAssmbPath = asmBase + "\\" + args.Name.Substring(0, args.Name.IndexOf(",")) + ".dll";
                break;
            }
    
        }
        //Load the assembly from the specified path.                    
        MyAssembly = Assembly.LoadFrom(strTempAssmbPath);
    
        //Return the loaded assembly.
        return MyAssembly;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say, I have a code snippet like this: public static void main(String[] args) {
I have a method that starts like this: public static UnboundTag ResolveTag(Type bindingType, string
I have some code like this: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Save([Bind(Prefix=)]Person person) { String s
I have a code like this: public static void ToUpperCase(params Control[] controls) { foreach
I have a piece of code that looks like this: public static T CreateSomething<T>(SomeType
I have extended IDictionary like this: public static T ToClass<T>(this IDictionary<string, string> source) where
If I have code like this: public XALServiceConfiguration CreateInstance() { var config = ConfigurationManager.GetSection(ConfigurationSectionName)
I have an enum whose code is like this - public enum COSOptionType {
I have code that looks like this: template<class T> class list { public: class
In our application, I have seen code written like this: User.java (User entity) public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.