Reputation: 336
I am working on an existing app that is in VB6 which is calling a .NET DLL. but my .NET code is not reflecting when it is called from the VB6 app. I have added one public propertt in the .NET app but when I try to access it, VB6 raises an exception:
"Object doesn't support this property or method"
My PostBuild event Code.
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe $(ProjectDir)bin\$(TargetName).dll /regfile:$(TargetName).reg
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe $(ProjectDir)bin\$(TargetName).dll /tlb:$(TargetName).tlb
I can see registry CLSID is changing. But code is not reflecting when calling from VB6 (Object doesn't support this property or method)
VB6 Code
Set frmApp = CreateObject("AssemblyName.Class1")
Do I need to do any other setting?
How to set references in VB6 to the new classid?
Upvotes: 2
Views: 3218
Reputation: 336
Done... I simply copied my DLL to C:\Program Files\Microsoft Visual Studio\VB98 and its working no need to deploy in GAC or /Codebase switch
Upvotes: 0
Reputation: 52518
You can mark your .Net classes with the ProgId attribute. This will prevent your clsid from changing everytime you compile.
If the clsid does not change, you do not have to un- and re-register your classes.
After a re-register, you also need to set your references in VB6 to the new classid. VB6 uses the clsid to search for the component.
After comment
VB6 has been a long time ago. I don't know if "reference" is the correct term. But you should remove the depency on the old library. And add a dependency to the new, just like you did the first time.
Upvotes: 3
Reputation: 941218
"Not reflecting" is very unclear. But as posted, these regasm.exe commands are not sufficient to let a VB6 program find the assembly. If it doesn't complain about creating the class object then you've used gacutil.exe some time in the past. And the GAC contains an old copy of your DLL. You will have to remove that old copy, use gacutil.exe /u
Modify the regasm.exe command line, add the /codebase option so it always uses the copy of DLL in the build directory instead of looking for the DLL in the GAC.
Upvotes: 1