Groups | Blog | Home
all groups > dotnet clr > february 2008 >

dotnet clr : GenerateCeeMemoryImage / GenerateCeeFile



knattetjatte@googlemail.com
2/13/2008 9:17:54 AM
Hello group,

I am using the unmanaged API to create assemblies, emitting methods
into it, adding VTableFixup-entries and then saving it to disk. Then I
use the managed methods from unmanaged code, using LoadLibrary/
GetProcAddress, which works fine. Pretty cool.

But..

The next step is to jump the generate-file-on-disk part and use
CeeFileGen's GenerateCeeMemoryImage() instead of saving it to disk and
this is where I am currently having issues.

My old code did GenerateCeeFile() in the end which wrote the HCEEFILE
to disk. I thought that GenerateCeeMemoryImage() could be used as a
replacement but it seems not.. see an excerpt of my code below and the
error message I get:

[ ... code which gets an ICeeFileGen instance and does emit-stuff
removed ... ]

void *p = NULL;
hr = ceefilegen->GenerateCeeMemoryImage(file, (void**)&p);

This fails with 183, "Error Already Exists" which I cannot make sense
out of. The sscli reference code for GenerateCeeMemoryImage() does not
return any such errors..

I would appreciate it if anyone with an insight into these things
could give me a hint or two on how to use the GenerateCeeMemoryImage
function.

/joakim
knattetjatte@googlemail.com
2/14/2008 5:26:52 AM
On Feb 13, 6:17=A0pm, "knattetja...@googlemail.com"
[quoted text, click to view]

For the archives..

It turns out you cannot set the output file name and then "change your
mind" and do GenerateCeeMemoryImage() so in my case I just had to
remove the call to SetOutputFileName() a bit earlier in the code and
it started working.

AddThis Social Bookmark Button