I created a new class project. I added a new COM object.
The .ddl contains a single Public Function and one Public method. The method contains one line of code, a msgbox.

I have "Register for COM interop" checked in the Project>Configuration>Compile page.
I have ComVisible(true) in the AsseblyInfo.vb file.
I use RegAsm to register the .dll and the .tlb
I have used RegAsm to create a .reg file and then imorted successfully into the registry.

Now I am pretty much out of tricks.

Here is the problem.

If I open Excel, and go to Macro I cannot add the .dll as a refernce. The exact message I get is "Can't add a refernce to a specified file".
I can reference the .tlb file and the Intelisense works. However, when the Excel Macro code runs I get the error, "Can't find file".

Even though I have tried to keep this simple, I am obviously doing something wrong.

I have zipped and posted the whole project at:
http://patrickdillonphotography.com/Computer/msgboxtextclass.zip

I don't really expect anyone to download it to solve my problem. But if you become as frustrated as I am, I thought it might help to see the actual files. Be aware that I enclosed the .reg file from the RegAsm process. You can view it by opening notepad first and browsing for it. Do not click on the .reg file as I think that might modify your registry.

Thanks,
pat

PS If I create a VB.net 2008 project I can reference this COM object and it works fine. But I need it to work in VBA and VB6.

Thanks for that article. It would not have resolved my problem. I found my
solution last evening.
I used an alternate method to register the .dll than was mentioned in that article. I placed the .dll in its own folder. Added that folder to the client computer's Environment Path. Then I used the RegAsm.exe found in the .Net 2.0 directory (c:\windows\Microcost.net\framework\2.0 or something close to that).
From a command prompt browse to the directory where the .dll is located. In my case it was C:\Release\SendEmail. Since I also placed the .net 2.0 directory into the Environment path I was able to type:
RegAsm sendemail /tlb /codebase
That registered the .dll and allowed me use the .tlb as a reference in Excel. But Excel threw an error everytime I tried to access the .dll (eventhough Intelisense worked fine).
I found Excel was loading a 1.XXX version of the .Net Framework and that was causing a problem with my .Net 2.0 .dll. I found that the Assembly Binding was not happening by using FusLogVw.exe (Fussion Log Viewer). It is part of a MS SDK. Google it to get the exact details.
I fixed the problem by creating an Excel.exe.Config. This file is just an XML file that tells Excel what order to try multiple .Net Frameworks. Again Google for a sample.
Later today I will try the GAC solution along with the .config.
Thanks for your help.
pat

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.