ExcelDna and DotNetOpenAuth

Oct 6, 2012 at 9:09 AM

Hi,

I'm trying to use DotNetOpenAuth in my ExcelDna project but when I add the dll to my project I get the following message when opening the xll in Excel:

A problem occured while an add-in was being initialized (InitializIntegration failed).
The add-in is built with ExcelDna and is being loaded from C:\...

What is wrong?

Best regards

/Niels

Coordinator
Oct 6, 2012 at 10:59 AM
Edited Oct 6, 2012 at 10:59 AM

Hi Niels,

It probably means you have dependency that is failing to load for some reason.

Maybe attach a debugger to Excel before loading your add-in, to look for error messages there. Or use the Fusion Logger to investigate: http://www.hanselman.com/blog/BackToBasicsUsingFusionLogViewerToDebugObscureLoaderErrors.aspx.

-Govert

Oct 6, 2012 at 4:36 PM

Hi Govert,

Thanks for your answer.

Using FusionLog I managed to figure out that the version of DotNetOpenAuth I'm using references System.Web.Mvc version=1.0.0.0. I'm quite sure I'm not using anything of the Mvc functionality in DotNetOpenAuth and when running my code as an console app it worked. But with ExcelDna this assembly was required.

I solved it by getting the System.Web.Mvc.dll from an ASP MVC 1.0 and will pack it with my xll so my user don't have to install it.

Thanks again!

Best regards
/Niels

Coordinator
Oct 6, 2012 at 9:52 PM

Hi Niels,

Are you perhaps putting the DoNetOpenAuth library in your .dna file as an <ExternalLibrary> rather than a <Reference>? That would cause Excel-DNA to enumerate through all the types in it, and thus cause the extra dependency to load.

If it is being referenced by your code, and you just want it packed, it should just be a <Reference> in your .dna file.

Regards,

Govert

Oct 6, 2012 at 11:13 PM

Yes, thats's what I'm doing. Didn't know about <Reference>. Will try this.

Thanks!

/Niels

Coordinator
Oct 7, 2012 at 12:44 AM

Yes - you can do something like 

<DnaLibrary>
   <Reference Path="Useful.dll" Pack="true" />
   <ExternalLibrary Path="AddIn.dll" Pack="true" />
</DnaLibrary>

And then only AddIn.dll is examined and exported to Excel, but both are packed, and if AddIn.dll tries to load Useful.dll it will be unpacked and resolved correctly.

-Govert

Oct 7, 2012 at 8:14 AM

Nice! Thanks.