AutoOpen and AutoClose

1,895 views
Skip to first unread message

RS DID

unread,
Jan 27, 2010, 5:38:01 PM1/27/10
to ExcelDna
I recently took my entire build environment (C#,.NET, ExcelDNA ) which
is on my local C: drive and did an XCOPY /E to another drive.

When I run my software from the C: drive the AutoOpen is called. When
I run the version that I moved to another drive the AutoOpen is not
called.

The directory structures are the same, my PATH environment variable is
the same.

Any ideas will be greatly appreciated.

Govert van Drimmelen

unread,
Jan 28, 2010, 3:48:10 AM1/28/10
to ExcelDna
Hi,

This is strange. Is the add-in loading properly, but the AutoOpen just
not called?
Did you just change the location, or the name of the add-in (and .xll)
as well?

Maybe your problem has to do with the version of
ExcelDna.Integration.dll that you are referencing.
Best is to try the add-in without having a copy of
ExcelDna.Integration.dll in the same directory (or your working
directory, or your path..?) You might have conflicting versions of the
ExcelDna.xll at runtime and ExcelDna.Integration.dll referenced at
compile-time.

You need only have a copy of ExcelDna.xll, called <YourAddin>.xll, the
<YourAddin>.dna file and any of your .dlls referenced at runtime. A
copy of ExcelDna.Integration.dll is embedded in the .xll, and need not
be distributed. Extra copies or different versions of
ExcelDna.Integration.dll might cause problems.

--Govert--

RS DID

unread,
Jan 28, 2010, 9:03:32 AM1/28/10
to exce...@googlegroups.com
Thanks for the quick response.  I removed the ExcelDna.Integration.dll from my "Install" directory.  The Install directory has the MyProject.xll, MyProject.dll, MYProject.tlb and MyProject.dna, which only has :

  <DnaLibrary>
<ExternalLibrary Path="MyProject.dll" />)
  </DnaLibrary>

I did not change the name of any of the modules.  I moved these modules from where I build the project to a different directory on a different drive. The drive is a network drive, if that matters.  I have the same directory on my C:drive and the XLL loads fine, Auto_Open is called. All is well.

On the network drive, The Auto-open is not called, yet all the functions in XLL are registered and are useable.  I am using the latest version of ExcelDNA (0.21)

Thanks again.




--
You received this message because you are subscribed to the Google Groups "ExcelDna" 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.


RS DID

unread,
Jan 28, 2010, 1:43:43 PM1/28/10
to exce...@googlegroups.com
Just a bit more information on this thread.  I can see that the ExcelDna.Integration.dll is not being loaded when I try to run the ExcelDna code from the network drive where I copied all the necessary files.   It loads fine, no matter where I put the modules on my C: drive. Thanks for your help

Govert van Drimmelen

unread,
Feb 2, 2010, 3:40:58 AM2/2/10
to ExcelDna
Hi,

Certainly no functions will be exported from your add-in if
ExcelDna.Integration.dll does not load - but it might load from a file
or from the embedded resource inside ExcelDna.xll.

Can you check whether the add-in AutoOpen is called in the network
scenario when your add-in is just a .dna file (you can try with
MoreSamples.dna in the distribution.)

Perhaps you can re-check that your .dll is referencing a version of
ExcelDna.Integration.dll that matches the ExcelDna.xll. this is the
only case I can think of where the Excel UDF functions would be
exposed, but the IExcelAddIn.AutoOpen not recognized and run.

Regards,
Govert

> >> exceldna+u...@googlegroups.com<exceldna%2Bunsubscribe@googlegroups.c om>

RS DID

unread,
Feb 2, 2010, 1:47:13 PM2/2/10
to exce...@googlegroups.com
Govert

I tried your suggestion, using the MoreSamples.dna file on our network drive and running the add-ins from the network drive.  The AutoOpen was called and the functions inside MoreSamples are exposed to Excel.

I have checked that my .dll is referencing the correct ExcelDna.Integration.dll ( 0.21) and the ExcelDna.xll

12/10/2009  11:46 PM            71,680 ExcelDna.Integration.dll
12/10/2009  11:46 PM           229,888 ExcelDna.xll

Does it matter where I reference the ExcelDna.Integration.dll?

BTW: My statement that the ExcelDna.Integration.dll was not loading is a red herring; it was loading.  I am using Systernals ProcessExplorer to see the DLL's that are loaded.

Nevertheless, I am still experiencing the problem of the AutoOpen not being called unless I run the software on my computer. 

Remember that my MyProject.dna files contains

 <DnaLibrary>
     <ExternalLibrary Path="MyProject.dll" />
 </DnaLibrary>

This Dll was created with C#.  All of my excel functions are in this module, including the AutoOpen.  I have one class that holds the Excel functions and that class derives from IExcelAddIn. Do I need an explicit path in the DNA file that specifies the .dll file?

Is there a case where even though I load the XLL that it does not load?  That is what I am seeing when I copy all of the files to another computer. AutoOpen does not get called and my functions are not getting registered.

Very confusing given everything works great on my computer.

Any chance this is an AppDomain problem?

Thanks for your help.

Rob D.




To unsubscribe from this group, send email to exceldna+u...@googlegroups.com.

Govert van Drimmelen

unread,
Feb 3, 2010, 3:10:55 AM2/3/10
to ExcelDna
Hi,

I am confused:

An earlier e-mail said: "On the network drive, The Auto-open is not


called, yet all the functions in
XLL are registered and are useable."

But now you say: "...when I copy all of the files to another


computer.
AutoOpen does not get called and my functions are not getting
registered."

If no functions are registered (and AutoOpen is also not called), you
might have .Net trust issues for the network location, and need to set
these with CasPol - check this thread:
http://groups.google.com/group/exceldna/browse_thread/thread/4af520086389839a/0a574583902c8d89?lnk=gst&q=caspol#0a574583902c8d89
and this StackOverflow question:
http://stackoverflow.com/questions/423504/net-2-0-application-from-network-share-without-fulltrust.
The behaviour changed in .Net 3.5 SP1.

If the functions _are_ registered, but your IExcelAddIn.AutoOpen is
just not running when deployed over the network, I am not sure what
the problem is...

Could you perhaps clarify the situation?

--Govert--

> > <exceldna%2Bunsubscr...@googlegroups.c om>


> > > >> .
> > > >> For more options, visit this group at
> > > >>http://groups.google.com/group/exceldna?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "ExcelDna" group.
> > To post to this group, send email to exce...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > exceldna+u...@googlegroups.com<exceldna%2Bunsubscribe@googlegroups.c­om>
> > .
> > For more options, visit this group at

> >http://groups.google.com/group/exceldna?hl=en.- Hide quoted text -
>
> - Show quoted text -

RS DID

unread,
Mar 4, 2010, 11:29:29 AM3/4/10
to exce...@googlegroups.com
Hi Govert
I apologize for the late reply and I am sorry for the confusing remarks. 

Let me try to restate:

I was having 2 issues.

1) When I load the ExcelDNA addin from a network drive, the AutoOpen is not called.  This is still true.  The functions in the XLL are registered and they are useable.  The AutoOpen is critical to my project because of the setup it does. So any help here will be greatly appreciated.

2)When I copied the ExcelDNA addin code to another computer's local hard drive I was unable to load the XLL.

This is no longer true.  I have solved this problem and can share with other users of ExcelDNA that the issue for me was that the computer I copied the ExcelDNA addin to did not have the Extensibility.dll on it. 

When I build my project now, I set the "Copy Local" property to True for the Extensibility.dll.  This will bring down to my local project a copy of the Extensibility.dll which I now make part of the distribution to local machines. 

I hope I was more clear this time. 

To unsubscribe from this group, send email to exceldna+u...@googlegroups.com.

Govert van Drimmelen

unread,
Mar 5, 2010, 4:00:22 AM3/5/10
to ExcelDna
Hi,

Maybe you still have permissions issues - did you run the CasPol
command.
In any event, the AutoOpen always seems to run fine in my tests, but
calls to XlCall.Excel(...) and presumably to the Excel COM interfaces
might have problems. You could test by simplifying your AutoOpen
function...

I tried the following:

1. I make a directory called CompiledSample.

2. I make a file called CompiledSample.cs with the following content:

using System.Windows.Forms;
using ExcelDna.Integration;
public class MyAddIn : IExcelAddIn
{
public void AutoOpen()
{
MessageBox.Show("Now in AutoOpen.");
}

public void AutoClose()
{
MessageBox.Show("Now in AutoClose.");
}
}

public class MyFunctions
{
public static double CompiledSin(double angle)
{
return (double)XlCall.Excel(XlCall.xlfSin, angle);
}
}

3. I make a file called MakeCompiledSample.bat with:

c:\windows\microsoft.net\framework\v2.0.50727\csc.exe /
reference:ExcelDna.Integration.dll,System.Windows.Forms.dll /
target:library CompiledSample.cs

4. I copy ExcelDna.Integration.dll from the distribution into the
directory CompiledSample.

5. I run MakeCompiledSample.bat, which creates the file
CompiledSample.dll.

6. I create CompiledSample.dna with:

<DnaLibrary Description="CompiledMoreSample Test Add-In"
Language="CS">
<ExternalLibrary Path="CompiledSample.dll"/>
</DnaLibrary>

7. I copy CompiledSample.dll, CompiledSample.dna and ExcelDna.xll to a
new server directory \\server\development\ExcelDna\, and rename the
ExcelDna.xll to CompiledSample.xll.

8. Test Run 1 - I open CompiledSample.xll from the network path. The
AutoOpen messagebox shows. In a sheet, the function =CompiledSin(1)
fails returning #ERROR. This is because the assembly can't call back
to Excel due to permissions issues.

9. I run "CasPol.exe -m -ag 1.2 -url file://server/development/exceldna/*
FullTrust" from a Visual Studio prompt on my machine.

10. Test Run 2 - I open CompiledSample.xll from the network path. The
AutoOpen messagebox shows. In a sheet, the function =CompiledSin(1)
returns 0.841470985. Everything seems OK.

Let us know how this compares with your experience.

Regards,
Govert

> >http://groups.google.com/group/exceldna/browse_thread/thread/4af52008...
> > and this StackOverflow question:
>
> >http://stackoverflow.com/questions/423504/net-2-0-application-from-ne...

> > > >http://groups.google.com/group/exceldna?hl=en.-Hide quoted text -


>
> > > - Show quoted text -
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "ExcelDna" group.
> > To post to this group, send email to exce...@googlegroups.com.
> > To unsubscribe from this group, send email to

Reply all
Reply to author
Forward
0 new messages