Visual Studio 2010 (Creating Excel DLL) "warning" no build


E

EagleOne

Visual Studio 2010 Beta

Attempting to build an Excel DLL with Visual Studio.

Did use Chip Pearson template but apparently 2010 may have changed the process.

Example of Division.vb

Option Explicit On
Option Compare Text
Option Strict Off
Imports XL = Microsoft.Office.Interop.Excel
Imports OFC = Microsoft.Office.Interop
Imports System
Imports System.Runtime.InteropServices
Imports Microsoft.Win32


<ClassInterface(ClassInterfaceType.AutoDual), ComVisible(True)> Public _
Class Division

Public Function DivideBy2(ByVal D As Double) As Double
Return D / 2
End Function

Public Function DivideBy4(ByVal D As Double) As Double
Return D / 4
End Function

<ComRegisterFunctionAttribute()> Public Shared Sub RegisterFunction(ByVal type As Type)
Registry.ClassesRoot.CreateSubKey(GetSubkeyName(type))
End Sub

<ComUnregisterFunctionAttribute()> Public Shared Sub UnregisterFunction(ByVal type As Type)
Registry.ClassesRoot.DeleteSubKey(GetSubkeyName(type), False)
End Sub

Private Shared Function GetSubkeyName(ByVal type As Type) As String
Dim S As New System.Text.StringBuilder()
S.Append("CLSID\{")
S.Append(type.GUID.ToString().ToUpper())
S.Append("}\Programmable")
Return S.ToString()
End Function

End Class


------ Build started: Project: MathNET, Configuration: Debug x86 ------
vbc : warning BC40059: A reference was created to interop assembly
'Microsoft.Office.Interop.Excel' because of an indirect reference created
by assembly 'Microsoft.Office.Tools.Excel.v9.0'. Consider linking assembly
'Microsoft.Office.Tools.Excel.v9.0'.
vbc : warning BC40059: A reference was created to interop assembly
'Microsoft.Vbe.Interop' because of an indirect reference created by
assembly 'Microsoft.Office.Tools.Excel.v9.0'. Consider linking assembly
'Microsoft.Office.Tools.Excel.v9.0'.
vbc : warning BC40059: A reference was created to interop assembly 'office'
because of an indirect reference created by assembly
'Microsoft.Office.Tools.Common.v9.0'. Consider linking assembly
'Microsoft.Office.Tools.Common.v9.0'.
vbc : warning BC40059: A reference was created to interop assembly 'office'
because of an indirect reference created by assembly 'Microsoft.Office.Tools.Excel.v9.0'.
Consider linking assembly 'Microsoft.Office.Tools.Excel.v9.0'.

Build started 5/27/2009 1:06:15 PM.

CoreResGen:
Processing resource file "My Project\Resources.resx" into
"obj\x86\Debug\MathNET.Resources.resources".
CopyFilesToOutputDirectory:
Copying file from "obj\x86\Debug\MathNET.dll" to "bin\Debug\MathNET.dll".
MathNET -> C:\MathNETFunctionLibrary\MathNET\bin\Debug\MathNET.dll
Copying file from "obj\x86\Debug\MathNET.pdb" to "bin\Debug\MathNET.pdb".
c:\Windows\Microsoft.NET\Framework\v4.0.20506\Microsoft.Common.targets(3171,9): error MSB3216:

Cannot register assembly "C:\MathNETFunctionLibrary\MathNET\bin\Debug\MathNET.dll" - access denied.
Please make sure you're running the application as administrator. Access to the registry key
'HKEY_CLASSES_ROOT\MathNET.Division' is denied.

Build FAILED.

Time Elapsed 00:00:01.20
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I have no experience in "linking 'Microsoft.Office.Tools.Excel.v9.0' -or-
'Microsoft.Office.Tools.Common.v9.0'.

MY best guess is that the Declarations in the Visual Basic need to change from:

Imports XL = Microsoft.Office.Interop.Excel
Imports OFC = Microsoft.Office.Interop
Imports System
Imports System.Runtime.InteropServices
Imports Microsoft.Win32

To: Pure guess which does Not work

Imports XL = Microsoft.Office.Interop.Excel.VB.9.0
Imports OFC = Microsoft.Office.Interop VB.9.0
Imports System
Imports System.Runtime.InteropServices
Imports Microsoft.Win32

Bottom line:

The error message states: Consider linking assembly 'Microsoft.Office.Tools.Excel.v9.0'
If I wanted to attempt the linking, here and how do I do it?

Thanks in advance, EagleOne
 
Ad

Advertisements

C

Chip Pearson

I can't reproduce the problem you report. I'm using VS2010. When you
installed Office 2003 and/or 2007, did you include the "NET
programmability" option? Beyond that, I'm not sure why you would get
the errors you describe. Keep in mind, of course, the VS2010 is still
in the test phase, so who knows what could be happening.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
E

EagleOne

Chip,

It took me a while but I was able to ascertain if 2007 Microsoft Office Primary Interop Assemblies
was installed. In fact I "Windows InstallI Cleaner'ed" it and re-installed it. I believe that is
essentially equivilent to "NET programmability" option ???

Currently, I am attempting a re-creation on the DLL.

BTW, I can get a MathNET.DLL with VS 2008 Express but I cannot get Excel to recognize it as either a
Com Addin or Automation Addin - even though Build process reports a successful Build.

Also I made sure that I used the MathNET.dll in the "release" folder.

TIA EagleOne
 
E

EagleOne

Finally, I was able to get VS 2010 to work as expected.

I made the mistake of adding to the References the "...V9.0" files available in VS 2010.

Once removed, all worked well with the Compiling/Building the DLL.

Now, I must learn how to properly call that DLL in VBA.

Thanks so much, Chip
 
Ad

Advertisements

E

EagleOne

As stated, I was able to get VS 2010 to compile, build, .msi and Setup.

Also, I was able to install into 2007 via Automation Addin. Both are listed in the Addins window

That said, entering =DivideBy2(1234) fails #Name?

Obviously, I have been through the loop so often that I fail to see my mistake. Thoughts?

Thanks EagleOne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top