all groups > dotnet interop > july 2003 >
You're in the

dotnet interop

group:

interop with unknown types


interop with unknown types felice pollano
7/9/2003 2:46:49 PM
dotnet interop: Hi all,
What I'm trying to do is something that maybe is a little tricky :)
Well, I'm tring to create a scripting Host Engine ( ie a conuterpart of
VBScript ) creating my dll in unmanaged code, and hosting the framework
inside in.
My objective is tu parse on the fly the code my user supply to my script
engine, and execute it.
This is not a big deal, but the scripting that I use, is supposed to work
with an existing environment, and it use a lot of AddNamedItem function.
Each "NamedItem" is indeed a COM interface to an object, but how can I call
method in C# code of an IUnknow com type ? Is there some way to do it ?
Thanks all !

Re: interop with unknown types Vadim Melnik
7/9/2003 5:29:13 PM
Hi,

[quoted text, click to view]

It's not clear, at least for me, what you need, can you be a more specific?
Do you want to expose C# class to script environment via
IActiveScript::AddNamedItem and have problem retrieving IUnknown interface
pointer for managed object or something else?

...
Regards,
Vadim.


Re: interop with unknown types felice pollano
7/10/2003 2:24:41 PM
Hi Vadim,

Not exactly.... I want to use C# as Script engine, so I create my script dll
in unmanaged code,and inside it I'm hosting the CLR.

( the objective is to give old applications hosting script engine tu use C#
instead ov vbscript )

The problem is that Named Items are COM object, but C# can't directly manage
them !

So I read some documentation and I reached this point: Create 'on the fly'
an interop dll for each named item... don't know if it's a good idea... tell
me your opinion, please :)

Sorry for misunderstanding: I know my english is poor.

Thanks,

Felix

[quoted text, click to view]

Re: interop with unknown types Vadim Melnik
7/10/2003 6:02:57 PM
Hi,

[quoted text, click to view]

Why do not use VSA to host JScript.NET or VB.NET? C# doesn't support
built-in late bound calls.

"Visual Studio for Applications Provides Customized Scripting Facilities for
Your .NET Project"
http://msdn.microsoft.com/msdnmag/issues/02/08/visualstudioforapplications/default.aspx


[quoted text, click to view]

Does Marshal.GetIUnknownForObject/Marshal.GetObjectForIUnknown help?


[quoted text, click to view]

Sorry, I didn't understand why do you need interop assembly? From previous
post, I see old Active Script used for scripting host, and it's COM based.
Just return IUnknown interface pointer retrieved from C# object inside
IActiveScriptSite::GetItemInfo implementation.


...
Regards,
Vadim.

Re: interop with unknown types felice pollano
7/11/2003 9:30:55 AM
Hi Vadim,

Thank you very much for your interest in this strange project idea :)

Well, you suggestion is surely the best for use with managed
environments....

the one I'm trying to do will cooperate with old legacy applications that
already exposes objects in the old scripting strategy. So I can change the
scripting language for a legacy unmanaged application to a new powerful one
(real c#).

My idea to simulate late bound calls is to use the
System.__ComObject.InvokeMethod. So I will inject in the user supplyed code
one class for each named item whit the same name.

Further, these (public) classes, will expose *static* methods or property
named as the ones contained in the original com object. I will do this in
the unmanaged portion of the environment, using the more confortable ( for
me ;) ) ITypeInfo.



[quoted text, click to view]
http://msdn.microsoft.com/msdnmag/issues/02/08/visualstudioforapplications/d
efault.aspx
[quoted text, click to view]

AddThis Social Bookmark Button