I haven't written a blog for a long time
This issue is how to use the. net dll in COM.
When the local machine (win7) is developed, it can be used directly under COM, and there is no problem at all, but the dll is exported to other machines (windows xp, win 2003, win 7, etc) as shown in the following figure.
The reason is that Visual Studio automatically writes one to the Registry during local development:
HKEY_CLASSES_ROOT\CLSID\{71F5F31E-D86B-4FF1-89CA-BFCC3B8117BA}\InprocServer32\CodeBase=<path to your assembly>
But other machines do not have this. What should we do?
The solution is as follows:
1. If you have previously registered unregister old dll
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>RegAsm.exe /unregister ./ClientDLL
/TransferFile.dll
Microsoft (R) .NET Framework Assembly Registration Utility 2.0.50727.3053
Copyright (C) Microsoft Corporation 1998-2004. All rights reserved.
Types un-registered successfully
2. register again:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>RegAsm.exe /codebase ./ClientDLL/T
ransferFile.dll
Microsoft (R) .NET Framework Assembly Registration Utility 2.0.50727.3053
Copyright (C) Microsoft Corporation 1998-2004. All rights reserved.
Types registered successfully
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>
Note: Before using/codebase, your dll must be singed. What is signed? See:
Best, test:
In Excel, you can call up the development interface directly by Alt + f11,
Test code:
Public Sub TestApp()
Dim obj As New TransferFile.TransferFile
Dim result As Boolean
result = False
result = obj.UploadFile("c:\xp_test.txt", "xp_test.txt", "D:\Test")
Debug.Print result
End Sub
Done.
There is another way to do this:
Put the DLL in GAC. Then register again. In this way, no/codebase is required during registration.
Reference: http://social.msdn.microsoft.com/Forums/nl-NL/clr/thread/65dc0c4a-a426-41a0-9e80-c7de37b10c73