我有两个项目“HOD”和“控制器”。Controllers 是一个命名空间为“Controllers”的类库。在 HOD 的代码文件中,我试图通过“使用控制器”来引用控制器命名空间。我在 HOD 项目中添加了对 Controllers 的引用,它确实显示在 VS2008 中的引用文件夹下。
当我构建项目时,我没有收到任何错误,但是当我去查看页面时,我收到错误“找不到类型或命名空间名称“控制器”(您是否缺少 using 指令或程序集引用?)” .
Controllers.cs(类库,控制器项目)
using System;
using System.Collections.Generic;
using System.Text;
namespace Controllers
{
public class Controller { }
}
index.aspx.cs(HOD 项目)
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Controllers;
public partial class HOD : Page
{
string sop() { return "sop"; }
protected void Page_Load(object sender, EventArgs e)
{
blahmsg.Text = sop();
}
}
该项目位于我们的网络服务器上,Controllers.dll 与 HOD.dll 位于同一 bin 文件夹中。在此先感谢您的帮助!
编辑:.sln 内容
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "T:", "T:\", "{1D5F28B3-E6A0-4CF8-B7A3-43121225C73E}"
ProjectSection(WebsiteProperties) = preProject
TargetFramework = "2.0"
Debug.AspNetCompiler.VirtualPath = "/T:"
Debug.AspNetCompiler.PhysicalPath = "T:\"
Debug.AspNetCompiler.TargetPath = "E:\DEV\webdev\webdev\PrecompiledWeb\T:\"
Debug.AspNetCompiler.Updateable = "true"
Debug.AspNetCompiler.ForceOverwrite = "true"
Debug.AspNetCompiler.FixedNames = "false"
Debug.AspNetCompiler.Debug = "True"
Release.AspNetCompiler.VirtualPath = "/T:"
Release.AspNetCompiler.PhysicalPath = "T:\"
Release.AspNetCompiler.TargetPath = "E:\DEV\webdev\webdev\PrecompiledWeb\T:\"
Release.AspNetCompiler.Updateable = "true"
Release.AspNetCompiler.ForceOverwrite = "true"
Release.AspNetCompiler.FixedNames = "false"
Release.AspNetCompiler.Debug = "False"
VWDPort = "53327"
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HOD", "Y:\HOD\HOD.csproj", "{5F523FB7-B902-4E6E-BAA9-C2EB37D69EC7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Controllers", "Y:\HOD\Controllers\Controllers.csproj", "{E6A16990-5FC6-4FE3-8DAB-CD2FEC8CF4FF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C8A12BBE-4483-4560-97A4-795F2E57D667}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C8A12BBE-4483-4560-97A4-795F2E57D667}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C8A12BBE-4483-4560-97A4-795F2E57D667}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{C8A12BBE-4483-4560-97A4-795F2E57D667}.Release|Any CPU.Build.0 = Debug|Any CPU
{A81C381B-1E12-49B0-8BC0-8532EF9F216F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A81C381B-1E12-49B0-8BC0-8532EF9F216F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A81C381B-1E12-49B0-8BC0-8532EF9F216F}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{A81C381B-1E12-49B0-8BC0-8532EF9F216F}.Release|Any CPU.Build.0 = Debug|Any CPU
{BD46969E-9D1C-419A-A82C-388E35BF7C13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BD46969E-9D1C-419A-A82C-388E35BF7C13}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BD46969E-9D1C-419A-A82C-388E35BF7C13}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{BD46969E-9D1C-419A-A82C-388E35BF7C13}.Release|Any CPU.Build.0 = Debug|Any CPU
{1D5F28B3-E6A0-4CF8-B7A3-43121225C73E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1D5F28B3-E6A0-4CF8-B7A3-43121225C73E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D5F28B3-E6A0-4CF8-B7A3-43121225C73E}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{1D5F28B3-E6A0-4CF8-B7A3-43121225C73E}.Release|Any CPU.Build.0 = Debug|Any CPU
{5F523FB7-B902-4E6E-BAA9-C2EB37D69EC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5F523FB7-B902-4E6E-BAA9-C2EB37D69EC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5F523FB7-B902-4E6E-BAA9-C2EB37D69EC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5F523FB7-B902-4E6E-BAA9-C2EB37D69EC7}.Release|Any CPU.Build.0 = Release|Any CPU
{E6A16990-5FC6-4FE3-8DAB-CD2FEC8CF4FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E6A16990-5FC6-4FE3-8DAB-CD2FEC8CF4FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E6A16990-5FC6-4FE3-8DAB-CD2FEC8CF4FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E6A16990-5FC6-4FE3-8DAB-CD2FEC8CF4FF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
编译器输出
------ 重建所有开始:项目:控制器,配置:调试任何 CPU ------ C:\Windows\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701, 1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" /reference:"C :\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:"C: \Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" /debug+ /debug:full /filealign:512 /optimize- /out:obj\Debug\Controllers.dll /目标:库 Class1.cs 属性\AssemblyInfo.cs
编译完成 -- 0 个错误,0 个警告 Controllers -> Y:\HOD2\Controllers\bin\Debug\Controllers.dll ------ Rebuild All started: Project: HOD, Configuration: Debug Any CPU ----- - C:\Windows\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:Y:\HOD2\Controllers \bin\Debug\Controllers.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Configuration.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework \v3.5\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll" /reference:C:\Windows \Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\Windows\Microsoft。NET\Framework\v2.0.50727\System.Drawing.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.EnterpriseServices.dll /reference:C:\Windows\Microsoft.NET\Framework\ v2.0.50727\System.Web.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Web.Extensions.Design.dll" /reference:"C:\程序文件 (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Web.Extensions.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Web.Mobile.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Web.Services.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference :"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" /debug+ /debug:full /optimize- /out:obj\Debug\HOD.dll /目标:库 index.aspx.cs index.aspx.designer.cs Properties\AssemblyInfo.cs
编译完成 -- 0 个错误,0 个警告 HOD -> Y:\HOD2\bin\HOD.dll ========== 全部重建:2 个成功,0 个失败,0 个跳过 ======= ===