This project has moved. For the latest updates, please go here.

GetImageMso Bug in 1.7.3?

Sep 8, 2015 at 7:08 PM
Hi

I'm trying to load some icons (for a custom task pane) using the GetImageMso method. However I failed with below exception which i understand to mean (also by looking at core.cs) that netoffice cannot find the Picture class within it's own Assemblies. Something that is not extremly surprising as it's within the external stdole library...

Is there some trick to make the stdole library part of the search path or is this simply a bug, that the GetImageMso method should use a custom proxy method (Or that netoffice should wrap the picture class) ?

Any ideas?

Br
Ask


Class 00020430-0000-0000-c000-000000000046:Picture not found in loaded NetOffice Assemblies

Currently loaded NetOfficeApi Assemblies

Loaded NetOffice Assembly:System.Guid[] PowerPointApi, Version=1.7.3.0, Culture=neutral, PublicKeyToken=2aedeb5ce89d4005

Loaded NetOffice Assembly:System.Guid[] OfficeApi, Version=1.7.3.0, Culture=neutral, PublicKeyToken=7c1c3e9d16cace88

Loaded NetOffice Assembly:System.Guid[] VBIDEApi, Version=1.7.3.0, Culture=neutral, PublicKeyToken=a3637beacf571e8a
Sep 8, 2015 at 8:10 PM
Edited Sep 8, 2015 at 8:11 PM
I got this working by making a custom version of netoffice where i have the GetImageMso() method which simply casts directly to IPictureDisp.

I did try using the CreateKnownObjectFromComProxy method first, but since all the stdole (I)Picture* stuff is interfaces, that fails when calling Activator.CreateInstance (as the interfaces does not have constructors).

Also i changed the method to return an stdole.IPictureDisp (as consistent with MS documentation) instead of an stdole.Picture as it did before (but i didn't test if both will work).

i.e. the code in my custom version is
public stdole.IPictureDisp GetImageMso(string idMso, Int32 width, Int32 height)
{
  object[] paramsArray = Invoker.ValidateParamsArray(idMso, width, height);
  object returnItem = Invoker.MethodReturn(this, "GetImageMso", paramsArray);
  return (stdole.IPictureDisp)returnItem;
}
while the official 1.7.3 code is
public stdole.Picture GetImageMso(string idMso, Int32 width, Int32 height)
{
object[] paramsArray = Invoker.ValidateParamsArray(idMso, width, height);
object returnItem = Invoker.MethodReturn(this, "GetImageMso", paramsArray);
stdole.Picture newObject = Factory.CreateObjectFromComProxy(this, returnItem) as stdole.Picture;
return newObject;
}
Sebastian: maybe you can provide some insight into what is the correct approach here?

Br
Ask
Coordinator
Sep 14, 2015 at 3:18 PM
hey men,

i did not realized stdole is more as a stupid helper in some early bind scenarios(interface implementations and so on..)
thats why i've been never created a wrapper for.

now i see its also used in MS Office methods and/or properties. i'm sorry for that.

what happen:
The NetOffice Invoker try to find the corresponding wrapper class for stdole.Picture in current application domain and failed because we dont have a wrapper here so far.

What i have to do is to create an stdole Wrapper in NO 1.7.4.
As Hotfix, i suggest you to use the NetOffice.Invoker directly.
Something like:
Invoker.MethodReturn(myInstance, "GetImageMso", new object[]{argument1, argument2});

(i need 5-7 days from now to create the stdole wrapper and want upgrade the current release as fast as possible)

*Sebastian
Sep 26, 2015 at 8:01 PM
Hi

Sorry for no reply - i missed the notification in my inbox.

I did use a hotfix like you suggested (basically i just copied the existing GetImageMso Wrapper but changed it so it cast the returned object directly to stdole.Picture

But i'm looking forward to a more complete fix

Br
Ask