CustomTaskPaneVB.dna

Feb 6, 2013 at 5:35 PM
Hi Govert,

First, thanks a lot for the great work of ExcelDNA. You take a lot of headache away and I'm very greatfull for that.

I'm new at programming in VB and I have an additional question about one of your examples in the DNA downloads files (see subject description).
I work with:
  • Windows7
  • Visual Studio 2010 Express
  • Excel 2007
I got it worked perfectly when loaded in Excel.
I looked at the code and you have in the second half of the dna file a class code for MyUserControl, what makes sense of course. I would like to use just for that part a VB project. The other parts of the dna file code, I like. I still want to use (show/delete ctp, ribbon etc...)

I tried it myself a little but because of my unexperience I was having trouble importing my dll right.
Can you point me to a place where I can find an example of this, of if you would help me with it in any way, I'll be glad.

Sorry for the bother, Govert. I'm new at this and I need well detailed directives to implement an UserControl VB project and make it behave as a CustomTaskPane in your dna file.

I hope I explained this well.

Regards,
Raymond.
Coordinator
Feb 6, 2013 at 7:55 PM
Hi Raymond,

I don't understand your problem well, but I'll try to answer.

It seems you want to put the UserControl code in a compiled .dll library, and still have the ribbon event handlers etc. in the .dna file. This should be possible - you have to check the following:
  • In the .dna file, add a <Reference Path="..."> tag so that the code in the .dna file will be able to reference the compiled library.
  • Be sure that your compiled library is marked as "Make Assembly COM-Visible" (or at least that your UserControl is marked <ComVisible(true)> (but you want to switch "Register from COM Interop" OFF).
Then in your .dna code you should be able to refer to the UsercControl type that is defined in the compiled code.

I hope this answers your question.

Regards,
Govert
Feb 6, 2013 at 8:38 PM
Hi Govert,

Thanks for the quick response.
You did understand it well. That is my issue.

I tried what you advise (earlier today), except of the 'COM Interop OFF' part. I will have to look into it to see where that must be turned off.
I then replaced the declarations a few times in the .dna to implement/import my .dll where you had put 'MyUserControl' and finally got Excel to load but with aan error (is actually in dutch) like:
my .dll is built in a newer runtime version than currently loaded...

I will give it a try again and let you know.
Coordinator
Feb 6, 2013 at 8:46 PM
Edited Feb 6, 2013 at 8:46 PM
Hi,
That error would suggest your compiled library is targeting .NET 4 (the default under VS 2010) but your add-in is loading version 2.0 of the .NET runtime. You can instruct the add-in to load version 4 of the runtime by adding an attribute to the DnaLibrary tag in the .dna file:
<DnaLibrary RuntimeVersion="v4.0" >
...
-Govert
Feb 6, 2013 at 9:32 PM
Of course ... !
My original error was changed because I modified to much but with this runtime correction and some abacadabra inherits/imports stuff, guess what:
I just got it worked :-))
Thank you a lot.

I appreciate the time you took to help me out.
Regards,
Raymond.