Quantcast
Channel: NetOffice - MS Office in .NET
Viewing all articles
Browse latest Browse all 1741

Commented Unassigned: Parameter not optional exception thrown [20295]

$
0
0
Hi,

I'm working through an example tutorial to create a VBA addin using VB.net. The tutorial is here:
http://www.mztools.com/articles/2012/MZ2012013.aspx

I'm deviating from the tutorial by utilising NetOffice interop assemblies instead of the tutorial recommendation to create my own private assemblies. I have managed to get most of the code working but get a "Parameter not optional" exception when I try to press one of the custom buttons on the menu.

My code can be accessed at:
https://github.com/rossknudsen/VbaAddin/tree/master

The error occurs at line 128 of connect.vb. Any help to understand what is going on would be much appreciated.

Regards

Ross
Comments: ** Comment from web user: SebastianDotNet **

the problem is identified.

in fact: NetOffice replace null argument values with System.Reflection.Type.Missing. (also for ref arguments) this replacement behavior cause problems for the ref's. (i'm sorry, ref argument in methods is a very rare scenario and i dont test this yet. btw: NetOffice is aware of ref arguments in event triggers. )

as hot fix: initialize your ref argument with "new object();" to avoid the NetOffice "replace behavior". if its not null then NetOffice dont touch them.

*Sebastian



Viewing all articles
Browse latest Browse all 1741

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>