Pb with Ole automation server and interface between vc6 and vc7...

Pb with Ole automation server and interface between vc6 and vc7...

Post by Emmanuel Derrie » Tue, 04 Feb 2003 18:26:10



Hi !
I have written an ole automation server few months ago, in VC6. I use MFC
for this project and I have a class CMyOleAutoServ which "encapsulates" an
interface IMyOleAutoServ.
I have an atl application which import my ole server TLB (#import ...
myserv.tlb) : I declare an instance of this Interface :
IMyOleAutoServPtr m_pIID;
and I open server by calling CoCreateInstance and QueryInterface with
IID_MyOleAutoServ.
With VC6, it works fine but in VC7, it doesn't work anymore. The
QueryInterface returns E_NOINTERFACE, whereas the server returns it ! (I
debugged the CCmdTarget::InternalQueryInterface).
What happens ?
Thanks for any help...

--
Emmanuel Derriey
WinLog SA : http://www.winlog.com

 
 
 

Pb with Ole automation server and interface between vc6 and vc7...

Post by Larry Brasfiel » Tue, 04 Feb 2003 21:43:48




Quote:> Hi !
> I have written an ole automation server few months ago, in VC6. I use MFC
> for this project and I have a class CMyOleAutoServ which "encapsulates" an
> interface IMyOleAutoServ.
> I have an atl application which import my ole server TLB (#import ...
> myserv.tlb) : I declare an instance of this Interface :
> IMyOleAutoServPtr m_pIID;
> and I open server by calling CoCreateInstance and QueryInterface with
> IID_MyOleAutoServ.
> With VC6, it works fine but in VC7, it doesn't work anymore. The
> QueryInterface returns E_NOINTERFACE, whereas the server returns it ! (I
> debugged the CCmdTarget::InternalQueryInterface).
> What happens ?
> Thanks for any help...

Did you run regasm on your .DLL?
On the machine which tries to instantiate
your server?  If not, lookup the docs for
regasm and see why you need to run it and
how to do so.

--
-Larry Brasfield
(address munged, s/sn/h/ to reply)

 
 
 

Pb with Ole automation server and interface between vc6 and vc7...

Post by Emmanuel Derrie » Tue, 04 Feb 2003 22:57:00


Thanks for your answer, but It seems not to work : I have an error : "this
file is not a valid .NET Framework assembly" !
However, I don't understand why I need to use "regasm" to register my ole
server whereas I register it using "regsvr32" !

--
Emmanuel Derriey
WinLog SA : http://www.winlog.com





> > Hi !
> > I have written an ole automation server few months ago, in VC6. I use
MFC
> > for this project and I have a class CMyOleAutoServ which "encapsulates"
an
> > interface IMyOleAutoServ.
> > I have an atl application which import my ole server TLB (#import ...
> > myserv.tlb) : I declare an instance of this Interface :
> > IMyOleAutoServPtr m_pIID;
> > and I open server by calling CoCreateInstance and QueryInterface with
> > IID_MyOleAutoServ.
> > With VC6, it works fine but in VC7, it doesn't work anymore. The
> > QueryInterface returns E_NOINTERFACE, whereas the server returns it ! (I
> > debugged the CCmdTarget::InternalQueryInterface).
> > What happens ?
> > Thanks for any help...

> Did you run regasm on your .DLL?
> On the machine which tries to instantiate
> your server?  If not, lookup the docs for
> regasm and see why you need to run it and
> how to do so.

> --
> -Larry Brasfield
> (address munged, s/sn/h/ to reply)

 
 
 

Pb with Ole automation server and interface between vc6 and vc7...

Post by Carl Daniel [VC++ MVP » Wed, 05 Feb 2003 00:04:06



Quote:> Thanks for your answer, but It seems not to work : I have an error :
"this
> file is not a valid .NET Framework assembly" !
> However, I don't understand why I need to use "regasm" to register my
ole
> server whereas I register it using "regsvr32" !

You don't.  regasm is used to register a .NET assembly so that it can be
loaded into a COM client.

-cd

 
 
 

Pb with Ole automation server and interface between vc6 and vc7...

Post by Carl Daniel [VC++ MVP » Wed, 05 Feb 2003 00:04:51



Quote:> Hi !
> I have written an ole automation server few months ago, in VC6. I use
MFC
> for this project and I have a class CMyOleAutoServ which
"encapsulates" an
> interface IMyOleAutoServ.
> I have an atl application which import my ole server TLB (#import ...
> myserv.tlb) : I declare an instance of this Interface :
> IMyOleAutoServPtr m_pIID;
> and I open server by calling CoCreateInstance and QueryInterface with
> IID_MyOleAutoServ.
> With VC6, it works fine but in VC7, it doesn't work anymore. The
> QueryInterface returns E_NOINTERFACE, whereas the server returns it !
(I
> debugged the CCmdTarget::InternalQueryInterface).
> What happens ?
> Thanks for any help...

Please elaborate a bit:  "with VC7" means exactly what:  you rebuilt the
ATL client with VC7?  You rebuilt the automation server with VC7?  Both?

-cd

 
 
 

Pb with Ole automation server and interface between vc6 and vc7...

Post by Emmanuel Derrie » Wed, 05 Feb 2003 02:17:35


Carl,
"With VC7" means that I have rebuilt both client and server projects with
VC7 !
The strange thing is that the server returns the good interface in
CCmdTarget::InternalQueryInterface but the QueryInterface on the client
returns E_NOINTERFACE !!!

--
Emmanuel Derriey
WinLog SA : http://www.winlog.com





> > Hi !
> > I have written an ole automation server few months ago, in VC6. I use
> MFC
> > for this project and I have a class CMyOleAutoServ which
> "encapsulates" an
> > interface IMyOleAutoServ.
> > I have an atl application which import my ole server TLB (#import ...
> > myserv.tlb) : I declare an instance of this Interface :
> > IMyOleAutoServPtr m_pIID;
> > and I open server by calling CoCreateInstance and QueryInterface with
> > IID_MyOleAutoServ.
> > With VC6, it works fine but in VC7, it doesn't work anymore. The
> > QueryInterface returns E_NOINTERFACE, whereas the server returns it !
> (I
> > debugged the CCmdTarget::InternalQueryInterface).
> > What happens ?
> > Thanks for any help...

> Please elaborate a bit:  "with VC7" means exactly what:  you rebuilt the
> ATL client with VC7?  You rebuilt the automation server with VC7?  Both?

> -cd

 
 
 

Pb with Ole automation server and interface between vc6 and vc7...

Post by Igor Tandetni » Wed, 05 Feb 2003 02:27:21


Check that the type library is registered properly. What you describe is
the sign of missing marshalling support, which for automation-compatible
interface requires a type library.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


> Carl,
> "With VC7" means that I have rebuilt both client and server projects
with
> VC7 !
> The strange thing is that the server returns the good interface in
> CCmdTarget::InternalQueryInterface but the QueryInterface on the
client
> returns E_NOINTERFACE !!!

> --
> Emmanuel Derriey
> WinLog SA : http://www.winlog.com


message



> > > Hi !
> > > I have written an ole automation server few months ago, in VC6. I
use
> > MFC
> > > for this project and I have a class CMyOleAutoServ which
> > "encapsulates" an
> > > interface IMyOleAutoServ.
> > > I have an atl application which import my ole server TLB (#import
...
> > > myserv.tlb) : I declare an instance of this Interface :
> > > IMyOleAutoServPtr m_pIID;
> > > and I open server by calling CoCreateInstance and QueryInterface
with
> > > IID_MyOleAutoServ.
> > > With VC6, it works fine but in VC7, it doesn't work anymore. The
> > > QueryInterface returns E_NOINTERFACE, whereas the server returns
it !
> > (I
> > > debugged the CCmdTarget::InternalQueryInterface).
> > > What happens ?
> > > Thanks for any help...

> > Please elaborate a bit:  "with VC7" means exactly what:  you rebuilt
the
> > ATL client with VC7?  You rebuilt the automation server with VC7?
Both?

> > -cd

 
 
 

1. COM Interop - CCW, Dual Interfaces and OLE Automation

Please help!

I have a complex scenario, where a Smalltalk (VSE) application acts at OLE
Client to a COM object written in .NET (C#) and exposed to COM by the CCW.
It worked fine in Beta 1, but MS have changed some things in Beta 2. Below
is a simplified example of the Class

[Serializable]
[ClassInterface(ClassInterfaceType.AutoDual)]
[GuidAttribute("37ab292f-42ce-4e45-8cfc-9e99d529edb3")]
public class Foo{
    public DateTime Bar1{
        return(DateTime.Today);
    }
    public ArrayList Bar2{
        return(new ArrayList());
    }

The class is compiled into a signed DLL, which is put in the GAC and
registered to COM with regasm.exe.
This is a simplified version of the Smalltalk code, simplified and converted
to VB like syntax.

IDispatch = CoCreateInstance(
    clsid := {37ab292f-42ce-4e45-8cfc-9e99d529edb3},
    iid := {00020400-0000-0000-C000-000000000046},
    controllingUnknown := NULL,
    context := CLSCTX_SERVER
)
This works fine and returns a pointer to the objects IDispatch interface.

ITypeInfo = IDispatch.GetTypeInfo(iTInfo := 0, lcid := STDOLE_LCID)
In Beta1, this returned the type info for the class interface definition. In
Beta2 this returns the type info for the IDispatch interface definition. I
found out that by applying the ClassInterface attribute with the value
AutoDual to the class, I can get the type info for the class interface (the
one that hold the Bar1 and Bar2 methods). Smalltalk kan now, using the
ITypeInfo interface determine names of methods, properties, parameters and
data types of parameters. Everything works fine! Can someone explain why, I
have to applu the AutoDual attribute?

Today = IDispatch.Invoke("Bar1")
This works fine!

Array_IDispatch = IDispatch.Invoke("Bar2")
This works fine, however!

Array_ITypeInfo = Array_IDispatch.GetTypeInfo(iTInfo := 0, lcid :=
STDOLE_LCID)
This returns the type info for the IDispatch interface and not the
_ArrayList interface (the one that holds the Add, Clear, Count, etc.
methods and properties). Smalltalks OLE interop has no chances to determine
what methods are available, and what parameters and what datatype have to be
passed to those methods. This worked fine in Beta1, I got the type info for
the ArrayList interface, not the IDispatch interface, however, it works
different in Beta 2. Have I done something wrong? What can I do to get the
correct ITypeInfo for the ArrayList?

TIA

2. Rename Administrator account

3. ENORMOUS Pb with VC7 linker optimisation !

4. Copy a file while impersonating - what's wrong?

5. Pb with VC7 with CString and VARIANT...

6. Trend Microsystem antivirus for SBS2000

7. How to use an exe OLE automation server in .NET ?

8. Does retail version of FP97 ship w/MSDN??

9. Generating a TLB file from OLE Automation Server

10. Problem when converting Vc6 workspace to vc7

11. Migrating custom wizards from VC6 to VC7

12. Migrate from VC6 to VC7

13. Implicit type conversion in VC6 and VC7-2003