Hi, It's hard to tell without you showing some actual IL rewriting code. First thing that pops into my mind is that if you use the .net type system when rewriting the IL, you'll get references to the .net runtime type system.
Like, if you import a reference to typeof(int), or a System.Type, or a MethodInfo, then it will use the running one. To avoid that you can simply use the Cecil type system. Jb On Mar 4, 2012, at 11:19 PM, einarwh wrote: > Hi, > > I'm a Mono.Cecil n00b trying to do some IL rewriting on Silverlight > assemblies, but I seem to be doing something wrong. The "tampered" > assemblies (after rewriting) look OK in ILSpy, except for the > references to .NET framework libraries, which include the > standard .NET v 4.0 (not Silverlight) of system.dll and mscorlib.dll. > I guess I must be doing something wrong when I'm importing types? I > tried to follow the recipe here: > http://stackoverflow.com/questions/9109506/mono-cecil-fails-to-process-a-silverlight-5-assembly > so I use the following code to read the assembly: > > var resolver = new DefaultAssemblyResolver(); > resolver.AddSearchDirectory(@"C:\Program Files (x86)\Reference > Assemblies\Microsoft\Framework\Silverlight\v4.0"); > var assembly = AssemblyDefinition.ReadAssembly( > assemblyPath, > new ReaderParameters { AssemblyResolver = resolver }); > > I still seem to have the same problem, though. How do I best debug > this? How can I spot that I've inserted a faulty reference to the > regular .NET v4 dlls? I'm trying to inspect the > TypeReference.Module.Runtime and TypeDefinition.Module.Runtime of the > various types I use, does that make sense? > > Any help would be greatly appreciated. > > Kind regards, > Einar > > -- > -- > mono-cecil -- -- mono-cecil
