We have a .NET dll "A" that is created by a third party. It exposes classes through a tlb to our VB6 exe application.
We also have our own .NET dll "B" that references .NET dll "A". "B" also exposes classes to our VB6 exe application through a tlb.
Now, the VB6 application has no problem using classes from either library in the VB6 code until we try to call a function in "B" that has a parameter type from "A". In that case, we get an error 430 or an error saying
"unable to cast com object of type 'system.__comobject' to type 'Type.From.Dll.A'"
What could be causing this? Is this normal?Answer1:
You problem is the different NET versions as you said.
In version 4 , the NET team introduced the <a href="https://msdn.microsoft.com/en-us/library/ee518876(v=vs.110).aspx" rel="nofollow">In-Process Side-by-Side Execution</a>
With this you can have different versions of the CLR running in your application.
But that is not what you want, so I think you should turn this feature off, using an app.config file:
<?xml version="1.0"?> <configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0"/> </startup> </configuration>
Please note, that while you are using the VB6 IDE, the process that requires an app.config is the VB6.exe, so I would also copy that app.config to the VB6 folder and renamed it as VB6.exe.config. <a href="https://stackoverflow.com/a/180895/3929185" rel="nofollow">See this answer</a>