1

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. Commented Dec 14, 2016 at 19:28

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

I wondered if this was a CLR isolation issue! I just didn't think I had the option of a using a config in this case! Didn't think to put it in with the VB6.exe. Thank you so much, worked perfectly! This saves me a lot of debugging headaches.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.