Hello again,

The advice you gave me was correct. I was able to call the function I
wanted, but I got a "Detected the use of a corrupted OBJREF: Possible GC
Hole" exception.
The method executes correctly, but then I get the exception....
I am calling the method inside the helper frame in the FCIMPL1(void,
GCInterface::CollectGeneration, INT32 generation) method (in the
comutilnative.cpp file), after the call to
g_pGCHeap->GarbageCollect(generation);

Is it necessary to erect another helper frame? If so, how is it done? I
tried to do so by adding another
HELPER_METHOD_FRAME_BEGIN_0();

after the other frame ended, but it didn't compile....

Thanks in advance for any help

Ricardo Mendes
Distributed Systems Group
INESC-ID Lisbon, Portugal


----- Original Message -----
From: "Jan Kotas" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 14, 2003 4:52 PM
Subject: Re: [DOTNET-ROTOR] When to call code after the GC


> - The parameter for g_Mscorlib.GetMethod should be
> METHOD__GC_MANAGER_2__GC_GO in your case. It is
> METHOD__##classid##__##methodid.
>
> - I don't think you can omit the first ARG_SLOT * parameter for
> pMD->Call(...). You can use NULL since you are not passing any
> parameters.
>
> - Your "Go" method takes one hidden "This" parameter since it is
> instance method. You should change the Go method to be static in C#.
>
> -Jan
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
> -----Original Message-----
> From: Discussion of the Rotor Shared Source CLI implementation
> [mailto:[EMAIL PROTECTED] On Behalf Of Ricardo Mendes
> Sent: Sunday, July 13, 2003 6:07 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [DOTNET-ROTOR] When to call code after the GC
>
> I tried what you suggested but it didn't work. I think I might have
> missed
> something.
> I created a test class and a test method in "identity.cs"
> (system\runtime\remoting), with the following code:
>
> public class GCManager2
> {
>     public int counter;
>     public Hashtable testTable = new Hashtable( );
>     public GCManager2( )
>     {
>         counter = 0;
>     }
>
>     public void Go( )
>     {
>         testTable.Add( counter.ToString(), counter );
>         counter++;
>     }
> }
>
> Then I added the following lines to "mscorlib.h":
>
> DEFINE_CLASS(GC_MANAGER_2, Remoting, GCManager2)
> DEFINE_METHOD(GC_MANAGER_2, GC_GO, Go, IM_RetVoid)
>
> Then in "comutilnative.cpp" I included mscorlib.h and added the
> following
> lines between the helper frames
> in GCInterface::CollectGeneration:
>
> MethodDesc *pMD = g_Mscorlib.GetMethod(GC_GO);
> pMD->Call(GC_GO);
>
> But when I build Rotor I get an error message because GC_GO is an
> unknown
> identifier.
>
> Where did I go wrong?
>
> Thanks again for any help,
>
> Ricardo Mendes
> Distributed Systems Group
> INESC-ID Lisbon, Portugal
>
>
> ----- Original Message -----
> From: "Jan Kotas" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, July 07, 2003 4:36 PM
> Subject: Re: [DOTNET-ROTOR] When to call code after the GC
>
>
> > MethodDesc::Call is used in the EE itself to call the managed code.
> Here
> > is an example from comutilnative.cpp:
> >
> >         MethodDesc *pMD =
> > g_Mscorlib.GetMethod(METHOD__EXCEPTION__GET_MESSAGE);
> >
> >         ARG_SLOT GetMessageArgs[] = { ObjToArgSlot(objException) };
> >         MessageString =
> > (STRINGREF)ArgSlotToObj(pMD->Call(GetMessageArgs,
> > METHOD__EXCEPTION__GET_MESSAGE));
> >
> >
> > In order to call your own method from the EE code, you need to add an
> > entry in clr\src\vm\mscorlib.h. Entry in mscorlib.h will give you the
> > METHOD__XXX constant. If your method has unusual signature, you may
> also
> > need to add an entry to clr\src\vm\metasig.h in order to complete the
> > entry in mscorlib.h.
> >
> > MethodDesc::Call should be used inside
> > HELPER_METHOD_FRAME_BEGIN/HELPER_METHOD_FRAME_END since it needs a
> valid
> > frame to be erected.
> >
> > If your method is not in mscorlib, I would recommend adding a small
> > method to mscorlib that will call your non-mscorlib method. Check
> > LoadISymWrapper method in
> > clr\src\BCL\System\Reflection\Emit\AssemblyBuilder.cs to see how to do
> > it.
> >
> > -Jan
> >
> > This posting is provided "AS IS" with no warranties, and confers no
> > rights.
> >
> > -----Original Message-----
> > From: Discussion of the Rotor Shared Source CLI implementation
> > [mailto:[EMAIL PROTECTED] On Behalf Of Ricardo Mendes
> > Sent: Monday, July 07, 2003 8:13 AM
> > To: [EMAIL PROTECTED]
> > Subject: [DOTNET-ROTOR] When to call code after the GC
> >
> > Hello all,
> >
> > What is the best place to call managed code after a GC? I tried to
> call
> > managed code after the
> > HELPER_METHOD_FRAME_END(); call in the
> > FCIMPL1(void, GCInterface::CollectGeneration, INT32 generation) method
> > (in
> > the comutilnative.cpp file)
> > but it just keeps on firing assertions. I want to call managed code
> > using
> > something like FFI. It would be great
> > to call the code I want from managed code but I don't know if it's
> > possible.
> > Any ideas regarding a place in which I can call managed code safely
> > after a
> > GC?
> >
> > Thanks in advance for any help...
> >
> > Ricardo Mendes
> > Distributed Systems Group
> > INESC-ID Lisbon, Portugal
> >

Reply via email to