Click here to Skip to main content
15,887,350 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I was looking at an article by Muhammad Musa Ali entitled "Exposing COM interfaces of a .NET class library for Late Binding"

I did Solution 1, which was to create a COM object using the COM class template of Visual Studio.NET.

So I have a .NET DLL that is exposed as a COM interface, and in the same solution I have a .NET container project that accesses it. The purpose of the COM object is to get a connection string out of app.config. I also added a property called "Color" that returns a simple string for testing purposes.

In the .NET container both properties work as expected returning the connection string and the color.

When I reference the DLL in VB6 the color property works fine but the connection string property fails with this error:

Overload resolution failed because no Public (Item) is most specific for these arguments:
    'Public ReadOnly Property Item(index As Integer) As String':
        Not most specific.
    'Public Property Item(name As String) As String':
        Not most specific.


I googled this error and I've spent over a day trying to get this working. If you have any idea what might be causing this I would greatly appreciate any advice.

Thanks,

Jerry
Posted
Updated 2-Nov-10 2:50am
v3

I also put some logging in the DLL. The connection string name is getting passed to the object.

It is apparently not finding the app.config file. I have the app.config file in the same directory as the test file for the VB6 project.
 
Share this answer
 
Comments
Nish Nishant 2-Nov-10 11:09am    
Ok, so your error now has nothing to do with the original error you mentioned in your initial question. This is now more to do with the config file not being found in the search path. Perhaps it needs to be in the same folder as the .NET assembly?
Jerry44 2-Nov-10 11:19am    
Yes, and I have no idea why it stopped giving that error.

I tried putting it in the folder with the .NET assembly at first and it didn't work. In researching it, it seems that it should go in the folder with the test project.

I found that if you change the name of the app.config to VB6Project.exe.config it works but only if it is compiled into an exe. For some strange reason it doesn't work when you step through the code in the VB6 project.

But at least it is working and I can live with that.

Thanks for taking a look at this.

Jerry
Jerry44 2-Nov-10 18:36pm    
Well, I've decided that this not working in debug mode will just not suffice, so I decided to use an INI file and it works just fine.

I regret that I spent so much time on this.
Are you sure you are passing a VB6 string to the property index argument? It needs to be a string, which will resolve to a BSTR (which is what the .NET String is exposed as in COM).
 
Share this answer
 
Comments
Jerry44 2-Nov-10 9:31am    
Yes. Here is the code:

Private Sub Form_Load()

Dim x As New JKConnect.MyConnect

Dim sColor As String
sColor = x.Color


Dim sConn As String
'sConn = x.ReadConnect("ConnectionString22")


Dim sName As String
sName = "ConnectionString22"
sConn = x.ReadConnect(sName)

End Sub

sColor returns "Blue"

sConn returns ""
Nish Nishant 2-Nov-10 9:36am    
And what line throws the error you mentioned?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900