unable to cast object after using exceldnapack

May 22, 2013 at 11:34 AM
In the assembly with the function I have an interface for other assemblies to implement.
In my udf function I create an object and try to convert to the interface

If I do not use exceldnapack.exe on the xll file everything works but after that I get the exception "Unable to cast object ...."
Coordinator
May 22, 2013 at 6:41 PM
Can you post your .dna file, and explain the relationship between the assemblies?

-Govert
May 23, 2013 at 7:01 PM
Edited May 23, 2013 at 7:02 PM
The dna file is like this:
<DnaLibrary Name="My First AddIn" RuntimeVersion="v4.0">
   <ExternalLibrary Path="MyLibrary.dll" Pack="true" />
</DnaLibrary>
Coordinator
May 23, 2013 at 10:06 PM
In the problem scenario, do you have a copy of the MyLibrary.dll next to your packed add-in?
Do you have a copy of MyLibrary.dll in the GAC?

Either of these might cause there to be two copies of MyLibrary.dll being loaded into the AppDomain.
Some combinations of assembly references and the packing, together with the quirky .NET assembly loading rules, can be very problematic.

-Govert
May 24, 2013 at 5:28 AM
I don't have the dll in GAC but I do have it next to the packed add-in.

After packing should I remove it from the same directory as the packed xll?
May 24, 2013 at 5:44 AM
I remove the dll and it worked.

Thank you.