How to Resolve the 'Error BC30369: Cannot Refer to an Instance Member of a Class from Within a Shared Method' in VB.NET

After converting a legacy project to a Windows project, why is Studio getting compilation errors?

Unexpected error has occurred during the library compilation process:
The assembly compilation returned the following errors:

  • (804) : error BC30369: Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.
  • (744) : error BC30369: Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.

Issue Description:

After the conversion of a legacy project into a Windows project, a compilation error may hinder the project's publication. A library compilation process may present an unexpected error and show the following error messages:

Unexpected error has occurred during the library compilation process:
The assembly compilation returned the following errors:
* (804) : error BC30369: Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.
* (744) : error BC30369: Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.
Main.xaml:BC31424: Type 'System.Data.DataTable' in assembly '0563aff2-e1cd-49d7-8452-38680e9e20ab, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' has been forwarded 
to assembly 'System.Data.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Either a reference to 'System.Data.Common, 
Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is missing from your 
project or the type 'System.Data.DataTable' is missing from assembly 'System.Data.Common,
Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.


Troubleshooting and Resolution:

These error messages are largely due to the use of system variables that could conflict with existing VB.Net classes or methods. Usually, if an "Imports System" directive is present at the top of the VB.NET file, the 'system' and 'systems' are likely reserved.

Snippet from UiPath Studio for 'Imports System'

image.png

To resolve this issue, replace the 'system' and 'systems' variables or arguments in UiPath Studio Project with a unique identifier, such as 'systemItemToWork'.


Note: Ensure to avoid using 'system' or 'systems' in the future as these are reserved, and may conflict with .NET namespaces or class names.

Continued Issues:

If all the above steps were performed and the issue is still unresolved, consider the following:

  1. Log a support ticket: Provide as much information about the issue as possible.
  2. Submit relevant logs: Include Diagnostic tool logs with the ticket.
  3. Share a sample project: Particularly, both Windows legacy and Windows versions can help diagnose the issue.

By following this guide, it should be possible to navigate and solve compilation errors observed after converting legacy projects to Windows. If issues persist, don't hesitate to reach out for further support or assistance.