• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 527
  • Last Modified:

System.Reflection.TargetException when using Framework 1.1, Framework 2.0 and COM Interop

Application is a VB6 - EXE  (C.EXE) calling 2 VB .NET 2003 Framework 1.1 DLLs (A.DLL and B.DLL) via COM interoperability on Windows XP.

OK - Configuration:
All runs without problems on Windows XP, if only the .NET Framework 1.1 is installed on the computer.

It also runs on Vista When Framework 1.1 and Compact Framework 2.0 is installed.

NOT OK Configuration:
On XP, if Framework 2.0 is added to the system, during a long running function in B.DLL following exception is raised after the function has been running for a while:

"An exception 'System.Reflection.TargetException' has occurred in DefaultDomain. However, no debuggers are registered that can debug this exception. Unable to JIT debug."
During the message is shown, the VB6 applications window disappears and the application exits.

We buildt a VB.NET test driver to replace the VB6.EXE (C.EXE) to avoid using COM Interoperability. With this configuration, we did not observe the error, but that does not hel us, since we need to use the VB6 Exe.

???   Are there any Framework Updates that need to be installed  ????
<ComClass(CalcAdapter.ClassId, CalcAdapter.InterfaceId, CalcAdapter.EventsId)> _
Public Class CalcAdapter
    Public Const ClassId As String = "813A471F-FA74-433a-9254-4852347F705D"
    Public Const InterfaceId As String = "31F29B03-119F-4c8e-B699-5700EFC6C41D"
    Public Const EventsId As String = "26F047BF-CF95-4478-A431-51CF2CB9F542"

Open in new window

  • 2
2 Solutions
For me, do not install Framework 2.0, because of .dll conflicts.

Framework version 2.0 has System.Reflection...

During run time of VB6 application,  Framework version 2.0 .dll's also listen too.

So when you run the VB6 program, VB6 call's with .dll's, and when Framework version 2.0 catchup, it also loads his own dll's.  Then conflicts occurs.

There's no need for Framework version 2.0,  you can use Framework version 1.1 in case.  There only difference is there additional components.

joachim58Author Commented:
The Application is a "standard-software". We do not have impact which frameworks are installed. If any user installed for example MS XML Notepad on his PC, Framework 2.0 will be there.
Is there any possibility to avoid the problems you mentioned? Build option for the .NET assemblies is "By default, app.config supports running on .NET Framework v1.1."
joachim58Author Commented:
We made up a MS support case and hope we have solved this problem with their answer:
Use a configuration file for the (VB6-EXE) application
for example: app-name.exe.config
In this configuration file you can add tags to control the .NET runtime, for example to prohibit use of .NET framework 2.0

		<requiredRuntime version="v1.1.4322"/>
		<supportedRuntime version="v1.1.4322"/>

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now