Xll locks

233 views
Skip to first unread message

newbie

unread,
Mar 23, 2012, 11:27:21 AM3/23/12
to Excel-DNA
In reference to an earlier post,

http://groups.google.com/group/exceldna/browse_thread/thread/ebb8ae85ad897017/7a4d6efc04446778?lnk=gst&q=lock#7a4d6efc04446778

I still haven't solved the issue that a library DLL which the XLL
depends on locks even though the XLL doesn't lock anymore. Would you
please let me know if there's any way around it at all? I resort back
to shuting down Excel after each change.

Thanks.

Govert van Drimmelen

unread,
Mar 23, 2012, 12:17:38 PM3/23/12
to Excel-DNA
Hi Candy,

If the library is loaded by the .NET runtime loader, it will indeed
remain locked.
(I'm not sure what you mean by 'the XLL doesn't lock anymore' - I
expect the .xll file to remain locked as long as the add-in is loaded
in the Excel process.)

You might need to put together a little example and an explanation of
what you want to do so we can look at the options more closely.

Regards,
Govert

On Mar 23, 5:27 pm, newbie <candy.chiu...@gmail.com> wrote:
> In reference to an earlier post,
>
> http://groups.google.com/group/exceldna/browse_thread/thread/ebb8ae85...

newbie

unread,
Mar 29, 2012, 3:15:11 PM3/29/12
to Excel-DNA
Govert, where should I send the example?
> > Thanks.- Hide quoted text -
>
> - Show quoted text -

Govert van Drimmelen

unread,
Mar 29, 2012, 3:46:42 PM3/29/12
to Excel-DNA
You can email me at gov...@icon.co.za.

-Govert

newbie

unread,
Mar 30, 2012, 10:03:39 AM3/30/12
to Excel-DNA
This solution contains 3 projects: Core, Lib, and Xll. Both Lib and
Xll references Core.

The xll and the dna file is in In ExcelDnaDemoXll\bin\Debug. I'd like
to load the latest Debug version of all 3 assemblies after
modifications. So far, modifying ExcelDnaDemoXll works. However,
ExcelDnaDemoCore and ExcelDnaDemoLib locks.

Eventually, all dlls will be placed in the same directory. According
to your comments in
http://groups.google.com/group/exceldna/browse_thread/thread/ebb8ae85ad897017/7a4d6efc04446778?lnk=gst&q=lock&pli=1,
placing them in the same directory will not work. But we can worry
about that later.

Thanks,

Candy
> > > - Show quoted text -- Hide quoted text -

newbie

unread,
Apr 13, 2012, 8:35:04 AM4/13/12
to Excel-DNA
Hi, Govert,

Any update on this?

Thanks,
Candy

On Mar 30, 10:03 am, newbie <candy.chiu...@gmail.com> wrote:
> This solution contains 3 projects: Core, Lib, and Xll.  Both Lib and
> Xll references Core.
>
> The xll and the dna file is in In ExcelDnaDemoXll\bin\Debug.  I'd like
> to load the latest Debug version of all 3 assemblies after
> modifications.  So far, modifying ExcelDnaDemoXll works.  However,
> ExcelDnaDemoCore and ExcelDnaDemoLib locks.
>
> Eventually, all dlls will be placed in the same directory.  According
> to your comments inhttp://groups.google.com/group/exceldna/browse_thread/thread/ebb8ae85...,

Govert van Drimmelen

unread,
Apr 13, 2012, 8:52:40 AM4/13/12
to exce...@googlegroups.com
Hi Candy,

Yes, I have had a look at the files you sent. I sent the reply below directly, but I repeat it here if it might be of interest to others.
I also attach a sample .dna file that shows how you could load and unload another add-in.

----

There were some changes that I made after the v 0.29 release to allow the references to resolve correctly if the library has been loaded 'from bytes' already. Without that, I think the libraries that are referenced from ExternalLibrary loaded .dlls will either have to be resolved from the same directory by the .NET loader, locking the file,

If I built the solution, then look in the ExcelDnaDemoXll\bin\Debug directory I see the .xll, .dna and three .dlls. But we don't want the .NET loader to resolve the ExcelDnaDemoCore.dll from that directory, so I first delete both ExcelDnaDemoCore.dll and ExcelDnaDemoLib.dll from the ExcelDnaDemoXll\bin\Debug directory. (You can set Copy Local=false for both of the references in the ExcelDnaDemoXll project too.)

Now I load the .xll in Excel. Both functions work and I am able to delete or change any of the three .dlls.

[An alternative to LoadFromBytes='true', and I can't quite tell the difference now, is to set ShadowCopyFiles="true" in the .dna file:
<DnaLibrary RuntimeVersion="v4.0" ShadowCopyFiles="true">

This also ensures that the .dll files won't be locked]

But I see there is a problem that reloading (via File->Open) the add-in does not reload the code. The new code does not get loaded because the assembly has already been resolved in the AppDomain.

One way around this is to use the add-ins dialog (press Alt+t then i) to load and unload the add-in every time.
You can also unload the add-in and reload from another add-in. I attach a .dna file with some code to load / unload as a start.

It's not so easy with the normal File->Open to completely recycle the AppDomain. I'd have to move some stuff to the unmanaged part, which is always tricky.
So for now I suggest you try either with the Alt+t, i add-ins dialog or having a separate meta-addin to help with the unloading.

Let me know whether you agree with the above.

Regards,
Govert

> --
> You received this message because you are subscribed to the Google Groups
> "Excel-DNA" group.
> To post to this group, send email to exce...@googlegroups.com.
> To unsubscribe from this group, send email to
> exceldna+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/exceldna?hl=en.
>
>
>
>
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 7050 (20120413) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>

AddInMadHost.dna
Reply all
Reply to author
Forward
0 new messages