I do realize. what i would like to achieve is to inject some tracing to this mixed assembly. how would you workaround this?
On Oct 9, 1:54 pm, Jb Evain <[email protected]> wrote: > Hey Gad, > > On Oct 9, 2011, at 8:36 AM, Gad wrote: > > > I need help to workaround the following scenario - a null reference > > when attempting to write an assembly that is written in cpp. > > It's not a nullref it's an ArgumentException. Something is wrong in the > object model. > > > how to reproduce: > > - In VStudio2010 create a .Net assembly by choosing Visual C++\CLR > > \Class Library. Build > > - I've added an empty method that accepts an int by it maybe > > redundant > > Could you attach your assembly here? > > > - Run the following code: > > string fileName = @"c:\dev\examples\cecil > > \InjectCodeToAssembly\CallAndInjectApp\bin\Debug\UnsafeLib.dll"; > > AssemblyDefinition assemblyDefinition = > > AssemblyDefinition.ReadAssembly(fileName, new > > ReaderParameters{ReadingMode =ReadingMode.Immediate}); > > assemblyDefinition.MainModule.Attributes= > > ModuleAttributes.ILOnly; > > assemblyDefinition.Write(fileName); > > Do you realize that by doing so, the re-written assembly will lose every > piece of native code it may contain, and thus be rendered unusable? > > Best, > > Jb -- -- mono-cecil
