BUG: "System.IO.FileIOException" error message when you run a project that indirectly references the Microsoft.VisualBasic.Compatibility library in Microsoft Visual Basic .NET (834610)



The information in this article applies to:

  • Microsoft Visual Basic .NET (2003)
  • Microsoft Visual Basic .NET (2002)

SYMPTOMS

When you run a Windows application project that indirectly references the Microsoft.VisualBasic.Compatibility library from Microsoft Visual Studio .NET 2002, the reference lookup fails, and you may receive the following error message:
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in system.windows.forms.dll
Additional information: File or assembly name Microsoft.VisualBasic.Compatibility, or one of its dependencies, was not found.

WORKAROUND

To work around the problem, follow these steps:
  1. Create an application configuration file that is named App.config for the MyRTMClientApp.exe Windows application project that you create in step 3 of the "More Information" section.

    For additional information about how to add the App.config file to the Windows application project, click the following article number to view the article in the Microsoft Knowledge Base:

    822752 PRB: Application configuration file is deleted when you build the solution

  2. Add the following code to the App.config file:
    <?xml version ="1.0"?>
    <configuration>
        <startup>
            <supportedRuntime version="v1.1.4322" safemode="true"/>
            <requiredRuntime version="v1.1.4322" safemode="true"/>
        </startup>
        <runtime>
            <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
                <dependentAssembly>
                    <assemblyIdentity name="Microsoft.VisualBasic.Compatibility" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
                    <bindingRedirect oldVersion="7.0.3300.0" newVersion="7.0.5000.0"/>
                </dependentAssembly>
            </assemblyBinding>
        </runtime>
    </configuration>
  3. Double-click MyRTMClientApp.exe to run the Windows application project.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

Steps to reproduce the problem

  1. To build a Class Library project in Microsoft Visual Basic .NET 2002, follow these steps:
    1. Start Visual Studio .NET.
    2. In Visual Basic Projects, create a Class Library project that is named MyRTMComponent.NET.
    3. On the Project menu, click Add Reference.

      The Add Reference dialog box appears.
    4. On the .NET tab, click the Microsoft Visual Basic .NET Compatibility Runtime component, and then click the System.Windows.Forms.dll component.
    5. In the Add Reference dialog box, click OK.
    6. Replace the existing code in the Class1.vb file with the following code:
      Public Class MyRTMClass
      
              Public Function MyCollection() As Microsoft.VisualBasic.Collection
      
              End Function
      
              Public Function MyDirListBox() As Microsoft.VisualBasic.Compatibility.VB6.DirListBox
      
              End Function
      
      End Class
    7. On the Build menu, click Build Solution to create the MyRTMComponent.NET.dll file.
    8. Save the MyRTMComponent.NET Class Library project.
  2. To create a Visual Basic .NET 2002 Windows application project, follow these steps:
    1. Start Visual Studio .NET.
    2. In Visual Basic Projects, create a Windows application project that is named MyRTMClientApp.
    3. On the Project menu, click Add Reference to add a reference to the MyRTMComponent.NET.dll file that you created in step 1 of this section.
    4. In the Add Reference dialog box, click OK.
    5. On the Project menu, click Add Reference to add a reference to the Microsoft Visual Basic .NET Compatibility Runtime component.
    6. In the Add Reference dialog box, click OK.
    7. On the Build menu, click Build Solution.
    8. Save the MyRTMClientApp Windows application project.
  3. To copy the Windows application project that you created in Visual Studio .NET 2002 to Visual Studio .NET 2003, follow these steps.
    1. Copy the MyRTMClientApp Windows application project that you created in step 2 of this section. Put the MyRTMClientApp Windows application project under C:\ on a computer that has Visual Studio .NET 2003 installed.

      Note The computer must not have Visual Studio .NET 2002 installed.
    2. Start Visual Studio .NET 2003.
    3. On the File menu, point to Open, and then click Project.
    4. Open the MyRTMClientApp Windows application that you put under C:\.
    5. Click Yes when you receive the message that prompts you if you want to update the MyRTMClientApp Windows application from Visual Studio .NET 2002 to Visual Studio .NET 2003.
    6. On the Build menu, click Build Solution.
    7. View the task list.

      Notice the following errors:

      Type '<class>' is not defined.
      The referenced component '<referenceddll>' could not be found.
    8. To solve the errors in step 3.g of this section, follow these steps:
      1. In the Solution Explorer window, expand References.
      2. Right-click MyRTMComponent.NET, and then click Remove.
      3. Right-click References, and then click Add Reference to add the MyRTMComponent.NET.dll component that is located in the C:\MyRTMClientApp\bin folder.
    9. On the Build menu, click Build Solution.

      Notice that the errors in the task list in step 3.g of this section do not appear.
    10. On the Debug menu, click Start.

      You may receive the error message that is mentioned in the "Symptoms" section.

REFERENCES

For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

318833 FIX: Visual Basic compatibility DLLs are missing from the Redist.txt file


Modification Type:MinorLast Reviewed:1/25/2006
Keywords:kbvs2005doesnotapply kbvs2005swept kbvs2002sp1sweep kbControl kbBug KB834610 kbAudDeveloper