开发者

Static Class Problem multi project

开发者 https://www.devze.com 2023-04-03 15:55 出处:网络
I have two applications and 1 class for database process. First Application is a Windows forms application like

I have two applications and 1 class for database process.

First Application is a Windows forms application like

public class Form1 :System.Windows.Forms.Form
{
  public Form1()
  {
  }
}

And my second application is a Windows control library application like

public class MyControl :System.Windows.Forms.UserControl
{
  public MyControl()
  {
  //
  //Some Code
  //
  }
}

and my class is static class like

public static class Deneme
{
  public static void Connect()
  {
  //
  //SomeCode
  //
  }

  public static void CreateTable(string SqlCommandP)
  {
  //
  //Some Code
  //
  }
}

I compile the control library application and get a .dll file. After that, I'm adding this file to Windows application project toolbox. I can use this control.

My problem is that:

I am using static class in a Windows application and control library application maybe I will make another control libary applicatio开发者_运维技巧n.

How can I use this static class from one project it have to be one in a project?


If the static class Deneme is to be shared between the 2 applications, you should place that static object in it's own library which both the WinForm project and the control project will reference.


Reference one project to the other? It seems like you're forgetting the Project Reference somewhere. Being more specific with the question might be helpful, though.

0

精彩评论

暂无评论...
验证码 换一张
取 消