Re: COM interop
From: Willy Denoyette [MVP] (willy.denoyette_at_pandora.be)
Date: 03/01/04
- Next message: Fakher Halim: "Re: Problem with regular expressions i .NET"
- Previous message: Dayton2: "foreach with a string and Hashtable"
- In reply to: C# beginner: "Re: COM interop"
- Next in thread: anonymous_at_discussions.microsoft.com: "Re: COM interop"
- Reply: anonymous_at_discussions.microsoft.com: "Re: COM interop"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 1 Mar 2004 20:48:47 +0100
What error do you get when calling Set o = CreateObject(....)
What attributes did you set on your methods, remember vbscript can only call
methods on objects implementing IDispatch (and dual) interfaces.
Here's a small sample that illustrates the attribute usage...
using System.Runtime.InteropServices;
using System;
// interface definition, dual to be script friendly
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[Guid("D3DF5658-3D3F-436b-B6A6-F10E77AE3F5F")] // Use guidgen to obtain
valid GUID's
public interface IDotNetInterface
{
int someMethod();
}
// class
[ClassInterface(ClassInterfaceType.None)]
[ProgId("Test.DotNetInterface")] // progid
public class DotNetInterface : IDotNetInterface
{
public int someMethod()
{
// Implemetation of someMethod, returning an int
return 0;
}
}
Check MSDN for details on InterfaceType and ClassInterface attributes.
The VBScript Client...
Set o = CreateObject("Test.DotNetInterface")
Dim var, ret
ret = o.someMethod()
WScript.Echo ret
Willy.
"C# beginner" <anonymous@discussions.microsoft.com> wrote in message
news:524501c3ffc1$030cd710$a101280a@phx.gbl...
> Thanks Willy. As I mentioned in my previous posting, I
> have registered my C# component using regasm and generated
> a tlb file. Per your suggestion, I tried using
> the /codebase option also. still doesn't work. Any help is
> appreciated.
>>-----Original Message-----
>>Placing your assembly in the GAC won't help a COM client
> to find the
>>assembly, COM has no idea what the GAC is.
>>What you should do instead is to register your assembly
> using the Codebase
>>option of regasm.
>>
>>Willy.
>>
>>"C# beginner" <anonymous@discussions.microsoft.com> wrote
> in message
>>news:4c0f01c3ffb8$7c812690$a301280a@phx.gbl...
>>> Hi all
>>> I am trying to call my C# class library from COM. My C#
>>> library works perfectly in the .NET environment. I have
>>> registered my C# component using regasm and also placed
> it
>>> in the GAC. But for some reason my VBScript COM
> component
>>> can't interop with .NET. I am calling my .NET component
> as
>>> follows.
>>>
>>> Set GSF = CreateObject("CSAppName.ClassName")
>>>
>>> Can you please tell me what I am missing? Thanks a lot
> for
>>> your help.
>>
>>
>>.
>>
- Next message: Fakher Halim: "Re: Problem with regular expressions i .NET"
- Previous message: Dayton2: "foreach with a string and Hashtable"
- In reply to: C# beginner: "Re: COM interop"
- Next in thread: anonymous_at_discussions.microsoft.com: "Re: COM interop"
- Reply: anonymous_at_discussions.microsoft.com: "Re: COM interop"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|