[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Harley Lagunov

11/14/2002 8:29:00 PM

How can I define/emit parameter type which is passed byref?
for example:
void MyFunc(ref MyClass myClass)
{
}

I can define/emit "System.Int32&" type, but can't '"SomeNamespace.MyClass&"?
---------------------------------------------------
Best regards,
Harley Lagunov


5 Answers

per larsen

11/15/2002 10:02:00 AM

0

I don't have the answer, instead I have an additional, related question:
How can I define/emit OUT parameter types with reflection emit?

- Per


Mattias Sjögren

11/15/2002 4:25:00 PM

0

Per,

>How can I define/emit OUT parameter types with reflection emit?

Make it a ref parameter, and then tag it with the
System.Runtime.InteropServices.OutAttribute.

To get a byref type, use Type.GetType() (or similar GetType method)
and append an "&" at the end of the type name.



Mattias

===
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.n...
Please reply only to the newsgroup.

per larsen

11/15/2002 7:47:00 PM

0

Thanks!

"Mattias Sjögren" <mattias.dont.want.spam@mvps.org> wrote in message
news:#lXTDsLjCHA.2240@tkmsftngp12...
> Per,
>
> >How can I define/emit OUT parameter types with reflection emit?
>
> Make it a ref parameter, and then tag it with the
> System.Runtime.InteropServices.OutAttribute.
>
> To get a byref type, use Type.GetType() (or similar GetType method)
> and append an "&" at the end of the type name.
>
>
>
> Mattias
>
> ===
> Mattias Sjögren [MVP] mattias @ mvps.org
> http://www.msjogren.n...
> Please reply only to the newsgroup.


Harley Lagunov

11/16/2002 1:59:00 AM

0

> >How can I define/emit OUT parameter types with reflection emit?
>
> Make it a ref parameter, and then tag it with the
> System.Runtime.InteropServices.OutAttribute.
>
> To get a byref type, use Type.GetType() (or similar GetType method)
> and append an "&" at the end of the type name.
>

If I try to use Type.GetType("MyNamespace.MyClass&") - returns null.
Type.GetType("System.Int32&") - returns int32& :((


Harley.


Harley Lagunov

11/16/2002 6:57:00 AM

0

Problem is solved:
Following code works fine - getting type from module where type defined:
//for pointer, array, byref types of types
private Type GetByRefType(Type type)
{
string clsName = type.FullName+"&"; //[], or *
Module mod = type.Module;
return mod.GetType(clsName);
}

--
---------------------------------------------------
Harley Lagunov

"per larsen" <perlATturbopowerDOTcom> wrote in message
news:#vuEOeNjCHA.3556@tkmsftngp08...
> Thanks!
>
> "Mattias Sjögren" <mattias.dont.want.spam@mvps.org> wrote in message
> news:#lXTDsLjCHA.2240@tkmsftngp12...
> > Per,
> >
> > >How can I define/emit OUT parameter types with reflection emit?
> >
> > Make it a ref parameter, and then tag it with the
> > System.Runtime.InteropServices.OutAttribute.
> >
> > To get a byref type, use Type.GetType() (or similar GetType method)
> > and append an "&" at the end of the type name.
> >
> >
> >
> > Mattias
> >
> > ===
> > Mattias Sjögren [MVP] mattias @ mvps.org
> > http://www.msjogren.n...
> > Please reply only to the newsgroup.
>
>