![](/img/trans.png)
[英]Changes made to the dll are not reflecting in the Application where I am using this dll
[英]I am adding dll in web application but that dll cannot access the class names what is the problem?
我在Web應用程序中使用dll(NEWDAO.dll)。 它有一個cs文件,我可以在Web應用程序中訪問該類的名稱,但是問題沒有解決,請給我任何建議
在NEWDAO名稱空間類中是DBConnection代碼是
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;
namespace NEWDAO
{
class DbConnection
{
private int _EmpName;
private string _Name;
private decimal _Salary;
private DateTime _CreatedDate;
public bool Flag = false;
DataSet ds = new DataSet();
SqlConnection m_Con = new SqlConnection("Server=*******,dataSource=Test,user name=sa,password=*******");
SqlCommand m_Cmd = new SqlCommand();
public int EmpNo
{
get
{
return _EmpName;
}
set
{
_EmpName = value;
}
}
public string Name
{
get
{
return _Name;
}
set
{
_Name = value;
}
}
public decimal Salary
{
get
{
return _Salary;
}
set
{
_Salary = value;
}
}
public DateTime CreatedDate
{
get
{
return _CreatedDate;
}
set
{
_CreatedDate = value;
}
}
/// <summary>
/// Insert the Emp values
/// </summary>
public bool EmpInsert()
{
Flag = false;
m_Con.Open();
SqlCommand m_Cmd = new SqlCommand("usp_EmpInsert", m_Con);
m_Cmd.CommandType = CommandType.StoredProcedure;
m_Cmd.Parameters.AddWithValue("@EmpName", EmpNo);
m_Cmd.Parameters.AddWithValue("@Name", Name);
m_Cmd.Parameters.AddWithValue("@Salary", Salary);
m_Cmd.Parameters.AddWithValue("@CreatedDate", CreatedDate);
if (m_Cmd.ExecuteNonQuery() >= 0)
{
Flag = true;
return Flag;
}
else
{
return Flag;
}
m_Con.Close();
}
/// <summary>
/// Display the values
/// </summary>
public bool EmpSelect(out DataSet oDS)
{
Flag = false;
m_Con.Open();
SqlCommand m_Cmd = new SqlCommand("usp_EmpInsert", m_Con);
m_Cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter ad = new SqlDataAdapter("usp_EmpInsert", m_Con);
ad.Fill(ds, "EMP");
if (ds != null)
{
oDS = ds;
Flag = true;
return Flag;
}
else
{
oDS = null;
return Flag;
}
m_Con.Close();
}
}
}
謝謝你的實力
您還應該檢查一下您的班級是否公開。 默認訪問修飾符是內部的。
類應該是公共的 ,以便從另一個程序集訪問。 如果未指定訪問修飾符,則“ 內部”為默認設置。
將類設置為public( public class DbConnection
)
添加對您的dll的引用
您可以按以下方式訪問該課程
NEWDAO.DbConnection
或者您可以添加一個using指令 ( using NEWDAO;
)並直接訪問DbConnection
您需要添加一個using
指令,該指令具有此類所在的名稱空間,或使用全名,包括名稱空間。
因此,如果完整的類名是:
DAO.SourceWordDoc
要么添加一個:
using DAO;
或使用全名DAO.SourceWordDoc
。
也許您的應用程序針對的目標框架不同於匯編程序。 例如,對於WPF項目,請檢查
屬性->應用程序->目標框架
可能您的DLL需要完整的框架,而您的應用僅針對客戶端配置文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.