1
votes

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?

1
It appears the issue is that dll A was created with a 2.0 target framework where as dll B is created with 4.5.1. Not sure if there is a good workaround for this or not. We don't want to return to a lower version of .NET just to get this working. - bzuillsmith

1 Answers

2
votes

You problem is the different NET versions as you said.

In version 4 , the NET team introduced the In-Process Side-by-Side Execution

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. See this answer