none
How to use a .net dll in Excel from shared network directory RRS feed

  • Question

  • Hello, I know this question have been asked a lot of time, but after a lot of searching and trying, I can't find a solution that works for me.

    I am developping a simple DLL that I want to put on a shared network directory and use in Excel VBA.

     

    I use VS2005 8.0.50727.42 , .net framework 2.0.50727, Excel 2002 10.6501.6623 SP3

    I have installed KB908002 on my machine

    On the target machine, same Excel , same .net framework.

     

    Here's the class

    <Microsoft.VisualBasic.ComClass()> Public Class testDll

    Public Sub New()

    MsgBox("New Ok")

    End Sub

    Public Sub Message()

    MsgBox("message ok")

    End Sub

    End Class

     

    Here's the code in Excel (after adding myDll.tlb in the references)

    sub test()

    dim toto as myDll.testDll

    set toto = new myDll.testDll

    toto.message

    end sub

     

    I generate the dll on the shared directory, checked the COM Interop. I now have myDll.dll and myDll.tlb in my network directory, which has FullTrust, on my machine and on the target machine.

    On my machine, works fine (after installing KB908002).

    On the target machine, I log in as an admin, run regasm.exe /codebase <path>\myDll.dll (tried regasm.exe /codebase /tlb <path>\myDll.dll also ).

    When I do 'set toto = new myDll.testDll', I get the error

    'Error '-2147024894(800700002)'

    Error Automation, can't find specified file

     

    I have been searching the net for days and tried everything I have read, I am at my wits end.

    (last lead I found was about the files in ...\SDK\v2.0\BootStrapper\Packages\KB908002 http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=174211&SiteID=1, but I am not sure if this concerns me, or how to use it)

    thanks in advance

    Cordially.

     

    Tuesday, March 11, 2008 3:57 PM

Answers

  • You should have a look with fuslogvw  which is part of the .Net Framework SDK. This tool will show you where your dll is searched and what the reason was that assembly probing did terminate.

    Yours,
      Alois Kraus

    Tuesday, March 11, 2008 11:26 PM
  • You can copy the tool on the other machine. It should have no other dependencies.

    Please have a look at the documentation of the tool. It does only set a couple of registry keys to enable fusion logging which will output html files in your configured output directory where you can watch them with IE.

     

    Select the Custom option button to view bind failures in a custom directory that you specify. You must specify the custom location where you want the runtime to store the logs by setting the registry key HKLM\Software\Microsoft\Fusion\LogPath to a valid directory name. This directory should be clean, and only contain files that the runtime generates. If it contains an executable that generates a failure to be logged, the failure will not be logged because the tool tries to create a directory with the same name as the executable. In addition, an attempt to run an executable from the log location will fail.

     

    Yours,

     Alois Kraus

     

    Wednesday, March 12, 2008 2:21 PM

All replies

  • You should have a look with fuslogvw  which is part of the .Net Framework SDK. This tool will show you where your dll is searched and what the reason was that assembly probing did terminate.

    Yours,
      Alois Kraus

    Tuesday, March 11, 2008 11:26 PM
  • I can't use fuslovw on the other computer as only .net framwork is installed, not sdk.

    As for my computer (on which it works fine), every assembly loads.

    And every assembly that I need is present on the other computer so I can't see any problem.

     

    Wednesday, March 12, 2008 8:46 AM
  • You can copy the tool on the other machine. It should have no other dependencies.

    Please have a look at the documentation of the tool. It does only set a couple of registry keys to enable fusion logging which will output html files in your configured output directory where you can watch them with IE.

     

    Select the Custom option button to view bind failures in a custom directory that you specify. You must specify the custom location where you want the runtime to store the logs by setting the registry key HKLM\Software\Microsoft\Fusion\LogPath to a valid directory name. This directory should be clean, and only contain files that the runtime generates. If it contains an executable that generates a failure to be logged, the failure will not be logged because the tool tries to create a directory with the same name as the executable. In addition, an attempt to run an executable from the log location will fail.

     

    Yours,

     Alois Kraus

     

    Wednesday, March 12, 2008 2:21 PM
  • Your idea was a good one, but I took the easy way and installed vs2005 to use fuslogvw.

    It seems that the Assembly Manager Loaded when I use VBA under Excel is C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\fusion.dll when it doesn't work, instead of C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll when it works.

    Any idea on how to change this ?

    And thanks for answering so quickly.


     

     

     

    Wednesday, March 12, 2008 3:15 PM
  • It seems that your target machine has only the .NET Framework 1.1 installed. Or did you use the regasm from .NET 1.1 by accident?
    Your COM object is activated by a specific .NET runtime which is stored in the InprocServer32 registry key. Have a look at your registered object with oleview.exe (also part of the Windows SDK). It seems that in these registry keys the wrong runtime is given to activate your object.

    Yours,
      Alois Kraus

    Wednesday, March 12, 2008 6:48 PM
  • I think I've got it :

    If I've understood correctly this article (http://msdn2.microsoft.com/en-us/magazine/cc163638.aspx), Office 2003 (and I suppose previous versions) don't use framework 2.0 until a fix has been installed.

    I've found two :

    to be installed on a computer with vs2005 : http://support.microsoft.com/kb/908002/en-us

    to be installed on a computer without VS2005 : http://www.microsoft.com/downloads/details.aspx?FamilyId=1B0BFB35-C252-43CC-8A2A-6A64D6AC4670&displaylang=en

     

    Seems th first one can be released with your applications, but I didn't go this far.

     

    Thanks for your time.

    Thursday, March 13, 2008 7:55 AM