将程序集引用添加到 WCF web.config 时出现问题
我正在尝试在 IIS 中托管 WCF 服务,以便可以从 Silverlight 应用程序访问 net.tcp 绑定。我一直在遵循本教程中的步骤:
http://msdn.microsoft.com/en-us/library/ms733766.aspx
我可以获得一个简单的示例类型服务来工作,但是当我尝试一个真实的项目时,我遇到了以下情况:
Line 6: using NUnit.Framework;
CS0246: The type or namespace name 'NUnit'
could not be found (are you missing
a using directive or an assembly reference?)
我知道你在想什么,是的,这是真的。我进行单元测试。
我的目录结构如下所示:
根目录:service.svc 和 app_code\
app_code:项目文件、web.config、bin\以及各个目录中的大量代码
bin:调试文件夹
调试:nunit dll 和项目二进制文件。
我尝试将以下内容添加到我的 web.config 中:
<compilation>
<assemblies>
<add assembly="nunit.framework"/>
</assemblies>
</compilation>
我也尝试过添加 .dll 和路径名等,但它们都会导致:
Could not load file or assembly
'nunit.framework' or one of its dependencies.
The system cannot find the file specified.
如何让魔法发生?
工具:VSE2010、IIS7 Express、MS WebMatrix
编辑: 将 web.config 文件更改为:
<add assembly="nunit.framework, Version=2.5.9.10348, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77"/>
按照 Steve 的建议就是答案 =)
I'm trying to host a WCF service in IIS so that I can access the net.tcp binding from a Silverlight app. I've been following steps from this tutorial:
http://msdn.microsoft.com/en-us/library/ms733766.aspx
I can get a simple example type service to work but when I try a real project I run into the following:
Line 6: using NUnit.Framework;
CS0246: The type or namespace name 'NUnit'
could not be found (are you missing
a using directive or an assembly reference?)
I know what you're thinking and yes it's true. I unit test.
My directory structure looks like this:
root: service.svc and app_code\
app_code: project file, web.config, bin\ and lots of code in various directories
bin: debug folder
debug: nunit dlls and project binaries.
I've tried adding the following to my web.config:
<compilation>
<assemblies>
<add assembly="nunit.framework"/>
</assemblies>
</compilation>
And I've played round with adding .dll and path names etc but they all result in:
Could not load file or assembly
'nunit.framework' or one of its dependencies.
The system cannot find the file specified.
How do I make the magic happen?
Tools: VSE2010, IIS7 Express, MS WebMatrix
EDIT:
Changing the web.config file to:
<add assembly="nunit.framework, Version=2.5.9.10348, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77"/>
As suggested by Steve is the answer =)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,我将使用程序集的完全限定名称。十分之九可以解决您的问题。 如何:确定程序集的完全限定名称 另外,请确保程序集它的所有依赖项都位于 GAC 或 BIN 文件夹中。
然后,如果您仍然遇到问题,Fusion 会准确地告诉您发生了什么:MSDN 上的 Fusion 日志查看器文档
First, I'd use the fully qualified name of the assembly. 9 times out of 10 that will fix your issue. How To: Determine an Assembly's Fully Qualified Name Also, make sure the assembly and all of it's dependencies are either in the GAC or in the BIN folder.
Then, if you're still having problems, Fusion will tell you exactly what's going on: Fusion Log Viewer Documentation on MSDN