Error (0x80070002) when dll is not in the same path from registration

Maxime Porté

First, the question is similar to Deploying .NET COM dll, getting error (0x80070002) but it didn't answer my problem.

I have build a dll (.net4) that I use with VBA in Excel / Word.

Principle:

  • I register the dll with regasm.exe from a temporary folder (no problem)

    RegAsm.exe `C:\temp\install\mydll.dll` /codebase
    
  • When Excel / Word load, the document (excel or word) load the dll in references

    Call ThisWorkbook.VBProject.References.AddFromFile("C:\working\anyfolder\mydll.tlb")
    

The folderpath can change depending the user (he create documents where he wants), and he can send documents to other users (if the dll is not in the folder, the document works in a degraded mode.

All of this works fine.

My problem: Recently I decided to improve the installation of this dll. When the installation finish I add a clean of the installation folder (C:\temp\install). But after doing that, when I try to use my dll in Excel / Word I have the error 0x80070002 File not found, even if the dll is in the folder of use (it's the same version of the dll I register)

What I know: I understood that he want the dll in the installation folder.

What I want:

  • Is there a way, after registration with regasm, to delete dll from installation folder and only use the one in the folder of documents (and move the dll from folder to folder depending needs).
  • Should I take a look at the GAC ? (I read the GAC wasn't needed if the dll is in the same folder as the document)

I read regasm documentation but found no information about it

If any other information is needed to anwser this, don't hesitate to ask.

Thanks a lot

update

To solve my problem, during the installation I add an installation to the GAC

(new Publish()).GacInstall("C:\temp\install\mydll.dll")

Publish needs a reference to System.EnterpriseServices

Thorsten Dittmar

The COM DLL needs to be present in the folder it was registered from all the time. You can use it in any application, but the Windows system needs to be able to find the DLL.

Your specific problem sounds like you should look into Office addin development.


There are little exceptions like Microsoft Dynamics NAV 5 that also require the DLL be present in the same folder as the application's executable, but I guess that's just a flaw in design and shouldn't normally be the case (in Dynamics: If you use the COM class both from the classic client and an application server, the COM-DLL needs to be present both in the classic-folder and the application server folder).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Loading a dll in c# from a relative path

Error when importing module from a different folder in the same parent directory

"More than one file was found with OS independent path" error when the same .jar is a dependency for both the app and a module

Error Code 0x80070002 when debugging C++ in VS19

Get a file from the same folder when importing (without hardcoding the path)

Load json from the same directory as .dll

Cannot open Files and getting error code 0x80070002 on C

Navigation Error when navigating to Home page from Firebase registration

Ansible error attribute not found due to same variable registration in multiple tasks

Can't load .dll file (HRESULT 0x80070002)

Windows 8.1 install error 0x80070002

LDAP-Error in Identity Server 4.6 when using user registration with "Ask password from user"

Symfony 2 and FOSUserBundle - add information from path to User during registration

Recieving error 80004005 on COM dll registration

Exception from hresult 0x8007007e ERROR for Port.dll in Spectrum Analyzer in vb

Why when adding dll file from Class Library project i'm getting error: Error on error Provider1?

Error 0x80070002 while installing Nokia device recovery tool

Error on registration of .dll module

Error executing a MapReduce from eclipse when hadoop is not in the same host

First C# real project (Exception from HRESULT: 0x80070002)

0x80070002 Error when creating a new .Net Core project in VS 2015 Community Edition

Error when calling c++ dll from delphi

Access x64 VBA - Getting ERROR_RESOURCE_DATA_NOT_FOUND when trying to load string from user32.dll

Syntax Error when invoking method from dll using "out" arguments

Error when pull data from dictionary and path-combine in pandas

Error code = 0x80070002 (MS Visual Studio) C++ for searching triplet data from one key element

Win32: What is HRESULT 0x80070002?

path error when running Pytest tests from cmd

ERROR Symlink path is the same as the target path (/vercel/path0/node_modules/next)