0
votes

I've been using the vb6 Interop Toolkit to allow me to use vb.Net usercontrols in a legacy vb6 application. I want to start using some features in .Net 4, but when I change the target framework on the .Net usercontrol project from ".Net Framework 2" to ".Net Framework 4", it builds ok, and runs ok on my development box, but when I deploy the app to a test box, the app fails upon startup with a "Out of Memory" error.

Here are some more details of how I'm experimenting...

Using VS 2010 with the Interop 2.1 Toolkit installed, I create a "VB6 Interop Usercontrol" project. I add a button to the default InteropUsercontrol.vb class (just so the control will be visible in the host app). I build the dll. I create a vb6 project (Project1) and reference the "InteropUsercontrolLibrary1" component from the vb6 Projects/Components/Controls dialog. I add the control to the form and compile Project1.exe. I then deploy Project1.exe, InteropUsercontrolLibrary1.dll, and Project1.exe.manifest (see below) to test machines (XP and Windows7) that have Framework 4.0 installed. With only these three files, the app runs fine. If I repeat the same process but change the target framework to 4.0, I get the Out of Memory error.

Here is my application manifest:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity 
        type="win32" 
        name="Test" 
        version="1.0.0.0" 
    />
  <dependency>
    <dependentAssembly>
      <assemblyIdentity 
        type="win32" 
                name="InteropUserControlLibrary1" 
                version="1.0.0.0" 
      />
    </dependentAssembly>
  </dependency>
</assembly>

The component manifest is automatically build by the Interop Toolkit pre-build events and embedded in the dll. It works with 2.0 so I expect it to with 4.0 also.

No matter what I do, I can't make a usercontrol written in .net 4.0 run in a vb6 application. Any suggestions would be appreciated.

Joel

2

2 Answers

1
votes

I stumbled over the same issue and found a solution.

The manifest of the Interop Usercontrol has to be modifed to make deployment work if .Net 4.0 is the target of the usercontrol. You have to add runtimeVersion="v4.0.30319" to the clrClass section.

The Interop UserControl manifest should look like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" 
  manifestVersion="1.0">
<assemblyIdentity
        type="win32"
        name="InteropUserControlLibrary1"
        version="1.0.0.0" />
<clrClass
        clsid="{f40e88ed-235a-4c9d-93a7-641ca0002635}"
        progid="InteropUserControlLibrary1.InteropUserControl"
        threadingModel="Both"
        name="InteropUserControlLibrary1.InteropUserControl"
        runtimeVersion="v4.0.30319" >
</clrClass>
</assembly>
0
votes

I don't know it this can help...

We had a "Out of Memory" error on a VB6 project with VB.Net user controls. It did happend at the VB6 compilation. After many hours of searching, it was beause a view property was made public and should have been friend since VB6 did not use it inour case and so must not see it. Ex:

<ComVisibleAttribute(False)> _
 Friend Property GroupValue() As String Implements IView.GroupValue
        Get
            Return Me.mPresenter.GroupValue
        End Get
        Set(ByVal value As String)
            Me.mPresenter.GroupValue = value
        End Set
    End Property