I'm trying to import a function into an existing assemby using: AssemblyDefinition assembly = AssemblyFactory.GetAssembly(<existing_assembly>);
MethodInfo func = typeof (CLASS_NAME).GetMethod(FUNCTION_NAME, new Type[0]); MethodReference funcref = assembly.MainModule.Import(func); the class's function and this code are defined in the same place. In addition i tried to execute this function from the existing assembly by modifying it's IL code: CilWorker worker = method.Body.CilWorker; Instruction instr = method.Body.Instructions[0]; Instruction writemissInstr = worker.Create(OpCodes.Call, funcref); worker.InsertBefore(instr, writemissInstr); when trying to execute the modified assembly program i got this error: Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'DSM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) File name: 'DSM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' when looking at the modified assembly manifest using ILDasm i see that there is a reference to the assembly containing the imported function but it has no public key token and I don't know why is that. I spent hours trying search this error msg in the web and implementing the offered solutions but nothing helped. does someone encountered this problem? can someone help me? --~--~---------~--~----~------------~-------~--~----~ -- mono-cecil -~----------~----~----~----~------~----~------~--~---
