locked
Reg Free Com with VB6.exe/C#.dll via Network Folder RRS feed

  • Question

  • Hi,

    for migrating our vb6 app i created a test scenario. The goal is to store vb6.exe combined with a c#-dll into a network folder and run it without any installation requirements (reg-free-com) from every win xp/net framework 2.0 - client in the network.

    Development environment:
    vb6 sp5
    visual studio 2008
    on WinXP Sp2 in a workgroup network

    First I builded a simple c#-dll:

    using System;

    using System.Runtime.InteropServices;

    namespace pbdcommon

    {

        [Guid("D6F88E95-8A27-4ae6-B6DE-0542A0FC7039")]

        [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]

        [ComVisible(true)]

        public interface MathFunctions_

        {

            [DispId(1)]

            int Multiply_(int x, int y);

        }

        [Guid("13FE32AD-4BF8-495f-AB4D-6C61BD463EA4")]

        [ClassInterface(ClassInterfaceType.AutoDispatch)]

        [ComVisible(true)]

        [ProgId("pbdcommon.clsTest")]

        public class clsTest : MathFunctions_

        {

            public bool IsInitialized;

            public clsTest()

           {

                IsInitialized = true;

           }

           public int Multiply_ (int x, int y)

           {

               return (x * y);

           }

        }

    }


    I choosed projekt properties options "Register for com interop", "make assembly com-visible", "sign assembly", then builded solution.

    According to the thread http://forums.msdn.microsoft.com/ru-RU/clr/thread/373e1d1f-e79f-45eb-85f4-115b09e43ec6/ I created a manifest for the dll with mt.exe:

    cmd /k "E:\Programme\Microsoft SDKs\Windows\v6.0A\bin\mt.exe" -managedassemblyname:pbdcommon.dll -nodependency -out:pbdcommon.manifest

    manifest content:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <assemblyIdentity name="pbdcommon" version="1.0.0.0" publicKeyToken="10534d49b300ebc2" processorArchitecture="msil">
    </assemblyIdentity>
    <clrClass clsid="{13FE32AD-4BF8-495f-AB4D-6C61BD463EA4}" progid="pbdcommon.clsTest" threadingModel="Both" name="pbdcommon.clsTest" runtimeVersion="">
    </clrClass>
    <file name="pbdcommon.dll" hashalg="SHA1">
    </file>
    </assembly>

    embedded the manifest into the dll with:

    cmd /k "E:\Programme\Microsoft SDKs\Windows\v6.0A\bin\mt.exe" -manifest pbdcommon.manifest -outputresource:pbdcommon.dll;#1

    a message appeared that re-signing the dll was necessary, so i re-signed it with

    cmd /k ""E:\Programme\Microsoft SDKs\Windows\v6.0A\bin\sn.exe" -R pbdcommon.dll <filename>.snk


    Then I made a simple vb-app project1.exe which references the c#-dll and uses it in the startup form:

    Private Sub Form_Load()

        On Error GoTo errorhandling

        Dim abc As New pbdcommon.clsTest
        MsgBox (abc.Multiply_(4, 2))
       
    errorhandling:

        If Err.Number <> 0 Then
       
            MsgBox (Err.Description & vbCrLf & Err.Number)
           
        End If

    End Sub

    This works fine in the IDE.

    I made a manifest for project1.exe:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
      <assemblyIdentity
                        type="win32"
                        name="ProBioData.Project1"
                        version="1.0.0.0"
                        processorArchitecture="x86"
      />
      <dependency>
        <dependentAssembly>
          <assemblyIdentity
                        name="pbdcommon"
                        version="1.0.0.0"
                        publicKeyToken="10534d49b300ebc2"
                        processorArchitecture="msil"
          />
        </dependentAssembly>
      </dependency>
    </assembly>

    Then I stored Project1.exe, pbdcommon.dll and Project1.exe.manifest in a network folder on a test pc with WinXP SP3, Net Framework 2.0.

    Running project1.exe from the local pc worked, but calling it from another client in the network produced the error:

    "Class does not support Automation or does not support expected interface 430" 

    All ideas gratefully received.

    Regards, Ulrich

    Thursday, June 19, 2008 8:44 AM

Answers

  • Hi Ulrich,

    Read this article about a whole sample to configure .NET-Based Components for Registration-Free Activation.

    Best regards,
    Riquel

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Tuesday, June 24, 2008 7:24 AM
    Moderator