Project with Reference to COM recompiling issue

M

Mullin Yu

I have a web services, and calling the VB COM which I add reference to my
project by

Reference -> Add Reference - > COM

But, if I modify my COM object, it seems that I need to remove the
reference from the project, and then re-add again.

Any ideas on this? Do I need to consider any late binding concept on c# like
those at vb6?

Thanks!
 
N

Nicholas Paldino [.NET/C# MVP]

Mullin,

Yes, this is correct. Most likely, you do not have binary compatability
set on your VB6 project. When you do this, you change the class id (CLSID)
as well as the interface ids (IID). These ids are stored in the interop
assembly that VS.NET generates. When you recompile your VB project, those
ids are changed, and VS.NET doesn't know what to do, since they don't exist
anymore.

If you want to get around this, take a copy of your compiled DLL, and
copy it to another directory. Then, under the project properties dialog in
VB6, select the "compatability" tab. On that tab, select binary
compatability and point to the copied dll. Now, when you build, the CLSID
and IID values will not be changed.

However, be careful, if you change the definition of public
methods/properties, you will break binary compatability, which means you
have to do a new build, and then create a new interop assembly in VB.

Of course, late binding gets around all of this, but that will mean more
coding time, and longer execution times.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top