Thank for update Brett - glad it's working now.
To be clear, the "Brett01" in Type.GetType("Brett01.MyUserControl1")
is the root namespace for your project, and not the name of the .xll
(though I guess these are the same in your case).
-Govert
On Mar 12, 5:07 pm, Brett Olson <
brettol...@cox.net> wrote:
> To all noobs like me that are just starting, here are the changes I needed
> to make to the sample CustomTaskPaneVB.net to get it working inside
VB.NET
> rather than the standalone .dna file.
>
> Three changes needed to be made.
>
> - As the .dna file suggests, I had to add the [ComVisible(true)]
> attribute to the, BUT... VB attributes use the '<' instead of '[', so the I
> added the following just above the class in myRibbon.vb
>
> Imports System.Runtime.InteropServices
> <ComVisible(True)> _
>
> - The following line caused an ArgumentNullException error when I used
> the .dna code
>
> *(From .dna file)* ctp =
> CustomTaskPaneFactory.CreateCustomTaskPane(Type.GetType("MyUserControl"),
> "Hello")
>
> *(Changed to) * ctp =
> CustomTaskPaneFactory.CreateCustomTaskPane(Type.GetType("Brett01.MyUserCont rol1"),
> "Hello") 'Brett01 is the name of my .XLL file and must be added!
>
> - As the .dna file suggests, I had to add the [ComVisible(true)]
> attribute to the User Control Class, BUT... VB attributes use the '<'
> instead of '['
>
> You can add this attribute in two different places, and it seems to in
> either location (otherwise you'll receive a COM error). Add this attribute
> either to the MyUserControl1.Designer.vb file, or add it to the
> MyUserControl1.resx file
>
> Imports System.Runtime.InteropServices
> <ComVisible(True)> _
>
> Thanks for help Govert. Hopefully, this helps the next person that is just
> getting started.
> > *System.ArgumentNullException was unhandled by user code*
> > * HResult=-
2147467261*
> > * Message=Value cannot be null.*
> > *Parameter name: type*
> > * ParamName=type*
> > * Source=mscorlib*
> > * StackTrace:*
> > * at System.Activator.CreateInstance(Type type, Boolean nonPublic)*
> > * at System.Activator.CreateInstance(Type type)*
> > * at
> > ExcelDna.Integration.CustomUI.CustomTaskPaneFactory.CreateCustomTaskPane(Ty pe
> > userControlType, String title, Object parent)*
> > * at
> > ExcelDna.Integration.CustomUI.CustomTaskPaneFactory.CreateCustomTaskPane(Ty pe
> > userControlType, String title)*
> > * at Brett01.MyRibbon.OnShowCTP(IRibbonControl control) in
> > C:\Users\BOlson\Documents\Visual Studio
> > 2012\Projects\Brett01\Brett01\myRibbon.vb:line 30*
> > * InnerException:*