# InvalidOleVariantTypeException

**URL:** https://talk.remobjects.com/t/invalidolevarianttypeexception/29647
**Category:** Oxygene
**Tags:** net
**Created:** [April 15, 2024, 7:35am UTC](https://talk.remobjects.com/t/invalidolevarianttypeexception/29647 "2024-04-15T07:35:56Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![Andreas\_Flucke](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@Andreas\_Flucke](https://talk.remobjects.com/u/Andreas_Flucke)
#### Post date: [April 15, 2024, 7:35am UTC](https://talk.remobjects.com/t/invalidolevarianttypeexception/29647/1 "2024-04-15T07:35:57Z")

</div>

Hi,  
the following code when run, produces this InvalidOleVariantTypeException

[Unbenannt 1.bugreport.zip](https://talk.remobjects.com/uploads/short-url/xe1Z0CSG7qYtFfBh4Hv0zN4ResP.zip) (7.4 KB)

[WaterException.txt](https://talk.remobjects.com/uploads/short-url/icz0HnxAIZt7G5j8fSYQIupNKwc.txt) (300 Bytes)

it seems the compiler emits wrong code.  
It is a long standing problem for me, which i have circumvent by using an old version of the compiler (Version 7.2.77.1621 from 2012)  
(I need this kind of code for my debugger)  
It would be nice to have this solved so that i can completely switch to the actual compiler.  
Thanks

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [April 15, 2024, 7:14pm UTC](https://talk.remobjects.com/t/invalidolevarianttypeexception/29647/5 "2024-04-15T19:14:14Z")

</div>

Andreas,

could it be that this declaration is incorrect:

```auto
    function Next([&In] celt:Cardinal;
                  [&Out, MarshalAs(UnmanagedType.LPArray, ArraySubType := UnmanagedType.IUnknown)] rgelt: array of Object;
                  [&Out] out pceltFetched:Cardinal):Integer;

```

The 2nd parameter has attribute `out` but it is declared w/o `out` modifier.

---

<div class="post-metadata">

### Author: ![Andreas\_Flucke](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@Andreas\_Flucke](https://talk.remobjects.com/u/Andreas_Flucke)
#### Post date: [April 16, 2024, 7:02am UTC](https://talk.remobjects.com/t/invalidolevarianttypeexception/29647/6 "2024-04-16T07:02:02Z")

</div>

I’ve changed/added every missing out modifier. But no luck…

---

<div class="post-metadata">

### Author: ![EvgenyK](https://talk.remobjects.com/user_avatar/talk.remobjects.com/evgenyk/32/16_2.png) [@EvgenyK](https://talk.remobjects.com/u/EvgenyK)
#### Post date: [April 16, 2024, 11:42am UTC](https://talk.remobjects.com/t/invalidolevarianttypeexception/29647/7 "2024-04-16T11:42:28Z")

</div>

Hi,

I’ve updated your declaration to

```auto
    function Next([&In] celt:Cardinal;
                  [&Out] out rgelt: ^Void;
                  [&Out] out pceltFetched:Cardinal):Integer; unsafe;

```

as I can see, code works and returns some value:

 ![](https://talk.remobjects.com/uploads/default/original/3X/f/b/fbf9c79d510de47af1187dab903b2207dbb68562.png)

---

<div class="post-metadata">

### Author: ![Andreas\_Flucke](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@Andreas\_Flucke](https://talk.remobjects.com/u/Andreas_Flucke)
#### Post date: [April 17, 2024, 6:42am UTC](https://talk.remobjects.com/t/invalidolevarianttypeexception/29647/8 "2024-04-17T06:42:29Z")

</div>

Yes, it seems to give some value.  
If you’ll find a way to do this without the unsafe modifier (which wasn’t needed with the old compiler) then it would be fine.  
Otherwise i would call this a regression…

---

<div class="post-metadata">

### Author: ![EvgenyK](https://talk.remobjects.com/user_avatar/talk.remobjects.com/evgenyk/32/16_2.png) [@EvgenyK](https://talk.remobjects.com/u/EvgenyK)
#### Post date: [April 17, 2024, 10:09am UTC](https://talk.remobjects.com/t/invalidolevarianttypeexception/29647/9 "2024-04-17T10:09:49Z")

</div>

Hi,

I’ve deleted your `IEnumUnknown` declaration and used `IEnumUnknown` type from [Microsoft.VisualStudio.OLE.Interop](https://www.nuget.org/packages/Microsoft.VisualStudio.OLE.Interop) nuget package:

 ![Untitled2](https://talk.remobjects.com/uploads/default/original/3X/4/d/4d2f199d0ad0a736e5d1877b6f2c2185cb16391e.png)

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [April 17, 2024, 12:14pm UTC](https://talk.remobjects.com/t/invalidolevarianttypeexception/29647/10 "2024-04-17T12:14:20Z")

</div>

> [@Andreas\_Flucke](#):
>
> If you’ll find a way to do this without the unsafe modifier (which wasn’t needed with the old compiler) then it would be fine.

“unsafe” should have no affect on Island, it’s only for .NET.

---

<div class="post-metadata">

### Author: ![Andreas\_Flucke](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@Andreas\_Flucke](https://talk.remobjects.com/u/Andreas_Flucke)
#### Post date: [April 18, 2024, 6:17am UTC](https://talk.remobjects.com/t/invalidolevarianttypeexception/29647/11 "2024-04-18T06:17:40Z")

</div>

Thanks for your investigation.  
But i don’t want to add an extra (unsafe) assembly.  
And i don’t want to rewrite my code.  
The old compiler was able to do that correctly, why don’t you accept this as a a bug/regression ?  
I can provide you with this version (and also the assembly for il comparision) in case you don’t have this version any more.

---

<div class="post-metadata">

### Author: ![EvgenyK](https://talk.remobjects.com/user_avatar/talk.remobjects.com/evgenyk/32/16_2.png) [@EvgenyK](https://talk.remobjects.com/u/EvgenyK)
#### Post date: [April 18, 2024, 12:15pm UTC](https://talk.remobjects.com/t/invalidolevarianttypeexception/29647/12 "2024-04-18T12:15:59Z")

</div>

Hi,

Logged and fixed as E26941.

Fix will be present in tomorrow’s build

---

<div class="post-metadata">

### Author: ![Andreas\_Flucke](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@Andreas\_Flucke](https://talk.remobjects.com/u/Andreas_Flucke)
#### Post date: [April 19, 2024, 6:27am UTC](https://talk.remobjects.com/t/invalidolevarianttypeexception/29647/13 "2024-04-19T06:27:40Z")

</div>

Thanx, that’s great !

Evgeny, i’ve tried to test your solution with the MS interop package, but i’ve got an  
error on compiling under 64 bit OS and an error on running on 32 bit OS.  
When running on my W10/32 bit OS, it seems the assemblies are not copied into the local bin directory. What do i miss ? Can you send me your project ?  
(I get a FileNotFoundException)  
When compiling under W10/64 bit OS, i get  
E: There was an exception executing the Elements compiler: ‘No path set for EBuildObject Reference: netstandard’

[RunException\_86.txt](https://talk.remobjects.com/uploads/short-url/8oPKcAb4Fu29RnLvkPcAZRUTuJ0.txt) (191 Bytes)  
[Unbenannt\_NuGet 1\_64.bugreport.txt](https://talk.remobjects.com/uploads/short-url/nTrzVJS3bf2FlFNCQjsFGcrSFEF.txt) (17.4 KB)  
[Unbenannt\_NuGet 1\_64.bugreport.zip](https://talk.remobjects.com/uploads/short-url/xFoEcJCyR5eUl6EdQA4NcWOoPc0.zip) (739.6 KB)

Thank you

---

<div class="post-metadata">

### Author: ![EvgenyK](https://talk.remobjects.com/user_avatar/talk.remobjects.com/evgenyk/32/16_2.png) [@EvgenyK](https://talk.remobjects.com/u/EvgenyK)
#### Post date: [April 19, 2024, 7:14am UTC](https://talk.remobjects.com/t/invalidolevarianttypeexception/29647/14 "2024-04-19T07:14:37Z")

</div>

Hi,

> [@Andreas\_Flucke](#):
>
> When running on my W10/32 bit OS, it seems the assemblies are not copied into the local bin directory. What do i miss ? Can you send me your project ?  
> (I get a FileNotFoundException)

You haven’t set `Copy local`:

 ![](https://talk.remobjects.com/uploads/default/original/3X/0/8/0843ebae084314d8beee518d297e8fc97b812670.png)

> [@Andreas\_Flucke](#):
>
> When compiling under W10/64 bit OS, i get  
> E: There was an exception executing the Elements compiler: ‘No path set for EBuildObject Reference: netstandard’

I can’t reproduce this. in my case all assembles were resolved as

```auto
   Reference 'mscorlib' was resolved to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\mscorlib.dll' for target 'Echoes'.
   Reference 'System' was resolved to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.dll' for target 'Echoes'.
   Reference 'netstandard' was resolved to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Facades\netstandard.dll' for target 'Echoes'.
   Reference 'System.Core' was resolved to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Core.dll' for target 'Echoes'.

```

---

<div class="post-metadata">

### Author: ![Andreas\_Flucke](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@Andreas\_Flucke](https://talk.remobjects.com/u/Andreas_Flucke)
#### Post date: [April 19, 2024, 8:11am UTC](https://talk.remobjects.com/t/invalidolevarianttypeexception/29647/15 "2024-04-19T08:11:21Z")

</div>

Thanks, i’ve overlooked the copy local flag. 32 bit now runs fine…

---

<div class="post-metadata">

### Author: ![Andreas\_Flucke](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@Andreas\_Flucke](https://talk.remobjects.com/u/Andreas_Flucke)
#### Post date: [April 19, 2024, 8:27am UTC](https://talk.remobjects.com/t/invalidolevarianttypeexception/29647/16 "2024-04-19T08:27:04Z")

</div>

Installing the ref assembies for 4.7.2 solved the problem with the 64 bit OS.  
(Although it’s unclear why)  
Thanks
