45590

Issue passing .NET object from VB6 to .NET

Question:

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>

Recommend

  • XGBOOST - DMATRIX
  • Getting EOFError along with exceptions when using ftplib
  • RavenDB indexing errors
  • Multiple Left Join LINQ-to-entities
  • Criterion causing memory consumption to explode, no CAFs in sight
  • Suqueries in select clause with JPA
  • Cannot get the UserManager class
  • Default parameter as generic type
  • TextToSpeech.setEngineByPackageName() triggers NullPointerException
  • Unable to install Git-core+svn by MacPorts
  • Unable to decode certificate at client new X509Certificate2()
  • How to handle images sent by a mobile device?
  • Needing to do .toArray() to get output of mongodb .find() on key name not value
  • The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin' does not exist or no valid ver
  • Recording logins for password protected directories
  • Pass value from viewmodel to script in zk
  • Launch Runnable Jar from Web Start
  • Symfony2: How to get request parameter
  • How to make Safari send if-modified-since header?
  • ORA-29908: missing primary invocation for ancillary operator
  • Akka Routing: Reply's send to router ends up as dead letters
  • How to pass list parameters for each object using Spring MVC?
  • AT Commands to Send SMS not working in Windows 8.1
  • VB.net deserialize, JSON Conversion from type 'Dictionary(Of String,Object)' to type '
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • Benchmarking RAM performance - UWP and C#
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • Hits per day in Google Big Query
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • How do I configure my settings file to work with unit tests?
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Linking SubReports Without LinkChild/LinkMaster
  • Is it possible to post an object from jquery to bottle.py?
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • JaxB to read class hierarchy
  • Binding checkboxes to object values in AngularJs
  • Net Present Value in Excel for Grouped Recurring CF
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?