ASP.NET网站项目的dll参考无法正常工作 [英] dll reference for ASP.NET website project not working

查看:65
本文介绍了ASP.NET网站项目的dll参考无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用C#创建了一个控制台应用程序来访问数据库.
后来,我将输出类型更改为类库".
该框架设置为.NET Framework4.

我创建了一个ASP.NET空网站项目.
我要添加对此的dll引用.

我尝试过的事情:
1.右键单击项目并添加引用->浏览到C#项目位置->从bin/debug文件夹添加.dll文件

-以上方法不起作用

2.我尝试从原始位置直接在ASP.NET网站的根项目文件夹中添加.dll文件,然后添加对该.dll文件副本的引用.
-这样做是在Bin文件夹下创建一个副本
-这也不起作用.

当我说它不起作用时,我正在尝试在ASP.NET网站中添加使用"引用. default.aspx.cs页没有任何名称空间(默认情况下).
另外,我检查了ASP.NET网站的.NET框架是否设置为.NET 4(不是.NET 4客户端).

有人可以建议出什么问题吗?您的帮助和想法将不胜感激.

P.S.当您在Bin文件夹中添加.dll文件时添加的.pdb文件在图标上有一个RedDot.暗示这可能是某种错误.当我编译类库的原始.cs文件时,未发现任何错误.另外,原始C#项目中没有主类,因为它是一个类库.

I have created a console application in C# to access databases.
Later, I changed the output type to Class Library.
the framework is set to .NET framework 4.

I have crated a ASP.NET Empty Website project.
I want to add my dll reference to this.

Things I''ve tried:
1. Right click project and add reference --> browse to C# project location --> add .dll file from bin/debug folder

--The above does not work

2. I''ve tried to add the .dll file from original location directly in root project folder of ASP.NET website, and then add a reference to this copy of the .dll file.
-- What this does is creates a copy under Bin folder
--This also doesn''t work.

When I say it doesn''t work, I''m trying to add a Using reference in the ASP.NET website. The default.aspx.cs page, does not have any namespace (by default).
Also, I''ve checked that .NET framework for ASP.NET website is set to .NET 4 (not .NET 4 client).

Can anyone please suggest what might be going wrong? your help and ideas will be greatly appreciated.

P.S. The .pdb file, which gets added when you add the .dll file in Bin folder, has a RedDot on the icon. Suggesting it might be some sort of an error. When i complied the original .cs file, of the class library, no errors were found. Also, no main class exists in original C# project, since it is a class library.

推荐答案

我认为.dll程序集可能已损坏.
我创建了另一个Windows-> 类库"项目.从旧项目中添加了现有项目".

创建了一个示例ASP.NET空网站.只需添加参考,即可再次导入.dll.再次导入了.dll文件.此外,.pdb文件的图标上仍带有红点.但是,这次键入.dll时成功显示了:使用< myImportedDllFile> ;;

这个问题已经解决,但是我不知道如何.如果还有其他人面临这个问题.他们可以尝试相同的方法.使用旧文件创建新库,然后尝试将新库导入测试项目中.从现在开始,它可以工作了,我可以在生产导入中使用它.
I think the .dll Assembly might have been corrupted.

I created another Windows --> "Class Library" project. Added "Existing Items" from old project.

Created a sample ASP.NET Empty Website. Imported .dll again, by just adding reference. Again the .dll file was brought in. Also, .pdb file still has the red dot on it''s icon. But the .dll showed up successfully this time when typing : using <myImportedDllFile>;

This issue is solved, but i don''t know how. If anyone else faces this problem. They can try the same approach. Create new library with old files, and try importing the new library in a test project. Since now it works, i can use it in my production import.


当您说"default.aspx.cs页面没有任何名称空间(默认情况下)"时,您是否表示您引用的程序集没有using语句,例如
使用系统;
使用System.Collection;

如果是这种情况,那么否,仅通过使用语句添加引用不会自动添加到文件中,您必须手动进行操作.
When you say "The default.aspx.cs page, does not have any namespace (by default)", do you mean the assembly you have referenced does not have a using statement, such as
using System;
using System.Collection;

If this is case, then no, just by adding a reference using statements are not automatically added to the files, you must do that manually.


这篇关于ASP.NET网站项目的dll参考无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆