如何在VB中访问公共变量.c#项目中引用的.Net模块



我有一个Visual Studio 2013解决方案与VB。Net项目(GL2015 -编译为DLL)和c#项目(PBIS -编译为Windows窗体)。GL2015 VB。. Net DLL在我的PBIS c#项目中被引用。基本上我是合并一个VB。. NET应用程序到我的c#应用程序。Net (GL2015)项目有模块,其中一个模块只包含全局变量。我采取了它的输入形式,并在我的c#项目中创建了一个。在移植代码后面的形式在我的c#应用程序,我注意到它引用这些全局变量。

这是我的问题。我如何从我的c#项目中引用这些"全局"变量,它们在VB中。网络模块?

VB。Net GL2015项目Global_Stuff.vb

Public Module Global_Stuff
'These items should be populated by PBIS data:
Public CustomerName, CustomerLocation, EndUser, EndUserLocation, Application, PurchaseOrderNumber, JobProposalNumber, ItemNumber As String
Public MaterialsList As List(Of String)
Public ApplicationsPath, MaterialPropertiesFile, ETODBConnectionString As String
Public ErrorMessage As String
Public ExistingProposal, JobMode, ExistingJob As Boolean
End Module

c# PBIS Project GL2015Form.cs

using GL2015;
...
Global_Stuff.ApplicationsPath = nodeToFind.InnerText;
...
MaterialPropertiesFile = nodeToFind.InnerText;

我应用了using GL2015;指令,但不能引用Global_Stuff模块。这意味着我必须插入一个"Global_Stuff"。的前面的所有全局变量在VB中引用。. NET项目(参见ApplicationsPath.)

是否有任何方法来引用这些全局变量在VB。. NET项目模块,而不必在我的c#项目中限定它们。在我的c#项目中,有超过100个全局变量被引用了700多次。

我在VB中使用过模块。Net存储数据库名称为什么?我厌倦了在其他表格上输入数据库名称好吧,所以当我搬到c#什么没有模块这是我用c#一步步解决WinForms的方法

创建两个表单这里的主要输入表单是frmStart我的第二个表单是frmDataModule下面是frmDataModule

中的代码
    public partial class DataModule : Form
{
    public DataModule()
    {
        InitializeComponent();  
    }
}
public class DBName
{
    // gv_dbName is used on frmStart
    public const string gv_dbName = "CheckBook.db";
}

下面是使用公共const

的frmStart的代码
    public void MyMethod()
    {
        string textToAdd = gv.strDatabase;
        {
            using (StreamWriter sw = File.AppendText(path))
            sw.Write(textToAdd + Environment.NewLine);
        }
    }

是的,这是一个老问题,我希望迟到的答案是有帮助的

最新更新