FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Creating a COM server with Juno

 
Post new topic   Reply to topic     Forum Index -> Juno
View previous topic :: View next topic  
Author Message
Numpsy



Joined: 22 Aug 2009
Posts: 27

PostPosted: Sat Aug 22, 2009 6:52 pm    Post subject: Creating a COM server with Juno Reply with quote

Hi all,

I'm new to D and have been having a play with creating a COM server using Juno (0.5.1, with D 1.046), and i've had a couple of problems.


The first thing i tried was to build the example from the juno.com.server docs, using a .def file to export the COM functions (DllRegisterServer etc), and that failed to link because the exported functions couldn't be found. I got it to build by adding some wrapper functions that call the 'real' ones defined by the Export mixin, but i'm wondering if it should work without that?


After that i ran into a problem where attempts to create an instance of the COM object failed with an E_POINTER error.
I think that's down to the
ppvObject = null;
in ClassFactory.CreateInstance (in juno/com/server.d). Changing it to
*ppvObject = null;
allows the object to be created and called.
Back to top
View user's profile Send private message
Numpsy



Joined: 22 Aug 2009
Posts: 27

PostPosted: Sun Aug 23, 2009 7:04 am    Post subject: Reply with quote

a couple of other things:

When i try to unregister the dll, i get a failure because it can't delete the registry keys. changing unregisterCoClass() from

scope clsidKey = RegistryKey.classesRoot.openSubKey("CLSID");

to

scope clsidKey = RegistryKey.classesRoot.openSubKey("CLSID", true);

allows it to succeed.


I also tried using D2 (2.031), and got a build failure:

juno\com\server.d(248): Error: function juno.com.core.GUID.toString () does not match parameter types (immutable(char)[])
juno\com\server.d(248): Error: toString can only be called on a mutable object, not const(GUID)

Marking the GUID.toString function as const allows it to compile.
Back to top
View user's profile Send private message
jcc7



Joined: 22 Feb 2004
Posts: 657
Location: Muskogee, OK, USA

PostPosted: Mon Aug 24, 2009 11:43 am    Post subject: Reply with quote

I seemed to have missed that 0.5.1 was even released, so I haven't tried it out yet. (I did update to 0.5, though.)

Juno can be very tricky to compile. (I think my troubles may be due to my use/misuse of DSSS, Bud, and/or DMD instead of a problem in Juno.)

I see that you've decided to try DWin instead. I hope that works for you. Good luck!
Back to top
View user's profile Send private message AIM Address
Numpsy



Joined: 22 Aug 2009
Posts: 27

PostPosted: Tue Aug 25, 2009 4:18 pm    Post subject: Reply with quote

Hi,
My actual intention was to try writing a COM addin for Outlook while trying to learn a bit of D, so i'm experimenting with Juno/Dwin and D1/D2 (though Juno doesn't seem to quite work with the latest D2 compiler).


I tried running tlbimpd on the Outlook type libraries yesterday and ran into the problem that you mentioned here.
I managed to debug tlbimpd and found what i think is a problem in Juno with unnamed parameters in the type libraries (i changed it so that it produces D files from mso.dll and msoutl.olb at least). I can post more info if you're still interested.
Back to top
View user's profile Send private message
jcc7



Joined: 22 Feb 2004
Posts: 657
Location: Muskogee, OK, USA

PostPosted: Sat Aug 29, 2009 3:58 pm    Post subject: Reply with quote

Numpsy wrote:
Hi,
My actual intention was to try writing a COM addin for Outlook while trying to learn a bit of D, so i'm experimenting with Juno/Dwin and D1/D2 (though Juno doesn't seem to quite work with the latest D2 compiler).


I tried running tlbimpd on the Outlook type libraries yesterday and ran into the problem that you mentioned here.
I managed to debug tlbimpd and found what i think is a problem in Juno with unnamed parameters in the type libraries (i changed it so that it produces D files from mso.dll and msoutl.olb at least). I can post more info if you're still interested.


You've come up with some changes to improve tlbimpd? I am interested.

I've actually started using my own tool (written in VB.NET, I'm embarrassed to admit) to generate import files for Juno since I've had trouble with tlbimpd. I wouldn't mind using tlbimpd again since my tool isn't perfect either.
Back to top
View user's profile Send private message AIM Address
Numpsy



Joined: 22 Aug 2009
Posts: 27

PostPosted: Sun Aug 30, 2009 7:10 am    Post subject: Reply with quote

The errors when importing the Outlook type library occur in the Parameter.getParameters function (at the end of com/reflect.d), when processing some property put functions.

For most of the property put functions the call to

typeInfo_.GetNames

returns a count of 2 and sets 2 strings in the array (usually the same, but sometimes different), but in a small number of instances it only returns a single item.
The problem is that the later

Code:
params ~= new Parameter(method, fromBstr(bstrNames[pos + 1]), paramType, pos, attrs);


tries to use the non-existant 2nd string (which was set to 0xbaadfood when i looked in the debugger, explaining the errors).

I fixed the error by changing it to use "value" if pos+1 is greater than the number of items in bstrNames, but i'm wondering if this is what the

Code:
        if ((funcDesc.invkind & INVOKEKIND.INVOKE_PROPERTYPUT) || (funcDesc.invkind & INVOKEKIND.INVOKE_PROPERTYPUTREF))
          bstrNames[0] = toBstr("value");


bit is supposed to do, as it doesn't appear to anything usefull at the moment.
Back to top
View user's profile Send private message
Numpsy



Joined: 22 Aug 2009
Posts: 27

PostPosted: Sun Aug 30, 2009 8:04 am    Post subject: Reply with quote

Another issue i had after that was that when i tried to use the generated .d file i got a load of errors about undefined types.

It turned out that the
Code:

   case TYPEKIND.TKIND_COCLASS:
      if (typeAttr.wTypeFlags & TYPEFLAGS.TYPEFLAG_FCANCREATE)
         types_ ~= new TypeImpl(typeInfo, TypeAttributes.CoClass, this);


In getTypes() was preventing some non-creatable coclasses from being defined, which caused errors because some of those classes are used as parameters for other functions.

I got a working file by removing the CANCREATE check, but i'm not sure what a 'proper' fix should be.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Juno All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group