trouble with hello world

130 views
Skip to first unread message

SA

unread,
Aug 29, 2010, 8:57:53 PM8/29/10
to Excel-Dna
Hello. I'm having issues trying to get a "Hello world!" UDF to work.

The content of the .dna file is:
<DnaLibrary Name="ExcelFunctions" language="VB" RuntimeVersion="v4">


<![CDATA[

Public Module MyFunctions

Function AddThem(x, y)
AddThem= x + y
End Function

End Module
]]>
</DnaLibrary>

When I double click on the .xll file I get this messagebox on Excel:

---------------------------
ExcelFunctions.xll Add-In Loader
---------------------------
This Excel add-in requires the Microsoft .NET Framework.



A problem occurred while attempting to load the requested version of
the Microsoft .NET runtime:

MetaHost could not load the requested version of the .Net runtime.



Please ensure that the that the correct version if the Microsoft .NET
Framework is requested by the add-in and that the required version is
installed.



This add-in is built with Excel-Dna and is being loaded from the
following location:

D:\Mis documentos\Visual Studio 2010\Projects\saea\saea\bin\Release
\ExcelFunctions.xll.
---------------------------
OK
---------------------------


However, I do have .net installed. Here are the versions in my system:

<32Bit>
2.0.50727.4952
->C:\Windows\Microsoft.NET\Framework\v2.0.50727
4.0.30319.1
->C:\Windows\Microsoft.NET\Framework\v4.0.30319

<64Bit>
2.0.50727.4952
->C:\Windows\Microsoft.NET\Framework64\v2.0.50727
4.0.30319.1
->C:\Windows\Microsoft.NET\Framework64\v4.0.30319

< Installed .NET Frameworks >
.NET FW 2.0 SP 2
.NET FW 3.0 SP 2
.NET FW 3.5 SP 1
.NET FW 4.0 Client
.NET FW 4.0 Full


Besides this particular issue, I don't quite understand the getting
started page examples. I want to code in VS and have the code in a .vb
file, in order to be able to enjoy the IDE (which you can't writing
inside CDATA blocks, as most examples do). I have written quite a lot
of lines of (hopefully good) VBA, but the transition to .net, even
with exceldna, isn't as smooth and easy as it should for someone who
has really no true programming knowledge.

Thanks!!

Govert van Drimmelen

unread,
Aug 30, 2010, 4:15:24 AM8/30/10
to Excel-Dna
Hi,

You have to be quite careful with the RuntimeVersion attribute. This
should be the full version name reflected in your .Net Framework
directory, i.e. RuntimeVersion="v4.0.30319" or one of the following
abbreviations:
RuntimeVersion="v2.0" means RuntimeVersion="v2.0.50727"
and RuntimeVersion="v4.0" means RuntimeVersion="v4.0.30319".

So your attribute RuntimeVersion="v4" should just be
RuntimeVersion="v4.0"

If you want to develop in Visual Studio, a nice set of step-by-step
instructions is here:
http://edparcell.posterous.com/tutorial-numerical-analysis-in-excel-using-c.

Basically, instead of having the code in the .dna file, you can add an
<ExternalLibrary Path="..." /> tag, which will load your compiled
library, written in any .Net language. In Visual Studio you make a
VB.NET library project with your code in, perhaps referencing
ExcelDna.Integration.dll. Then compile this to a .dll, and create
a .dna file with an ExternalLibrary tag pointing at your .dll, and a
copy of ExcelDna.xll with the same name as the .dna file (need not be
the name of the .dll). In the Debug settings in Visual Studio you pick
Excel.exe as the process to start, load the .xll and you should be
able to debug your project.

Hope this helps. Please feel free to post back if you have some more
questions.
I would also love for it to be easier to transition from VBA to Excel-
DNA :-)

Regards,
Govert

SA

unread,
Sep 3, 2010, 11:10:03 PM9/3/10
to Excel-Dna
I've followed the tutorial, however I can't get it to work.

The eat2.dna file has:

<DnaLibrary Name="eat2" language="VB" RuntimeVersion="v4.0">
<ExternalLibrary Path="eat2.dll" />
</DnaLibrary>

the eat2.vb file has:

Public Class eat2
Function hola()
hola = "hola"
End Function
End Class

I've also added a reference to Exceldna.integration, and there's the
eat2.xll (exceldna version 0.27).

I compile, double click on the .xll, excel asks if I want to enable
the addin only for the session (yes), then nothing happens. The
function doesn't show up, and eat2 doesn't show on the addins dialog
inside excel.

Govert van Drimmelen

unread,
Sep 4, 2010, 3:28:58 AM9/4/10
to Excel-Dna
Hi,

Functions exposed to Excel must be 'Public Shared' functions (called
'public static' in C#). You must either mark your function hola as
Shared, or make eat2 a public module, where all functions are
automatically static.

Regards,
Govert

Gareth

unread,
Oct 13, 2010, 7:08:19 AM10/13/10
to Excel-Dna
Hi Govert

I've got a user who's also getting this error message. The .dna file
is fine and passes all tests on my VMs:

* Windows XP 32bit, Office 2003, .Net 4.0 Full
* Windows XP 32bit, Office 2007, .Net 4.0 Full
* Windows 7 64bit, Office 2010, .Net 4.0 Full

The user is running XP, Office 2003, .Net Full

Do you have any other ideas regarding this, or what I can do to debug
it?

Thanks,
Gareth.

Govert van Drimmelen

unread,
Oct 13, 2010, 7:20:14 AM10/13/10
to Excel-Dna
Hi Gareth,

I presume you mean the "MetaHost cannot load..." message
What does the DnaLibrary tag look like?

--Govert--

Gareth Hayter

unread,
Oct 13, 2010, 7:24:59 AM10/13/10
to exce...@googlegroups.com
Hi Govert

Yes, the "MetaHost cannot load..."

The DnaLibrary tag is:
<DnaLibrary Name="XXXX" Description="XXXXXXXXX" RuntimeVersion="v4.0" Language="CS">

The full error the user receives is:

---------------------------

XXXXX.xll Add-In Loader

---------------------------

This Excel add-in requires the Microsoft .NET Framework.

A problem occurred while attempting to load the requested version of the Microsoft .NET runtime:

                MetaHost could not load the requested version of the .Net runtime. 

Please ensure that the that the correct version if the Microsoft .NET Framework is requested by the add-in and that the required version is installed.


Thanks,
Gareth.

--
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.


Govert van Drimmelen

unread,
Oct 13, 2010, 7:33:46 AM10/13/10
to Excel-Dna
Hi Gareth,

I've had no reports of problems on .NET 4.

Perhaps the user does not have .NET 4 installed, or has the beta
version of .NET 4 installed. You'll need to check his .NET 4
installation carefully.

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

Gareth

unread,
Oct 13, 2010, 5:00:17 PM10/13/10
to Excel-Dna
Hi Govert

You were correct. It turned out to be a beta version.

Thanks,
Gareth.
> > > exceldna+u...@googlegroups.com<exceldna%2Bunsubscr...@googlegroups.c om>
Reply all
Reply to author
Forward
0 new messages