本文介绍了找不到名称空间"ServiceModel";与Unity的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的Unity应用程序中使用WCF服务(通过命名管道).因此,我包括以下两个命名空间:

I would like to use a WCF Service (via Named Pipe) in my Unity application. Thus, I include the following two Namespaces:

using System.ServiceModel;
using System.ServiceModel.Channels;

在Unity中运行项目后,会导致以下两个错误:

After I run my project in Unity, this leads to the following two errors:

Assets/Scripts/program.cs(4,14): error CS0234: The type or namespace name ServiceModel' does not exist in the namespaceSystem'. Are you missing an assembly reference?

Assets/Scripts/program.cs(5,14): error CS0234: The type or namespace name ServiceModel' does not exist in the namespaceSystem'. Are you missing an assembly reference?

接下来,我将Unity脚本编辑器从MonoDevelop更改为Visual Studio2013.在Visual Studio中打开相同的脚本后,对术语"ServiceModel"加下划线(之字形红线),Visual Studio表示此命名空间不可用.手动添加"System.ServiceModel"后,这些红线消失了.但是,当我从Unity运行它时,我再次遇到相同的错误.另外,当我重新启动Unity并回到Visual Studio中的该脚本时,再次必须手动添加"System.ServiceModel".

Next, I changed the Unity script editor from MonoDevelop to Visual Studio 2013. After I open the same script in Visual Studio, the term "ServiceModel" is underlined (zigzag red line) and Visual Studio says that this Namespace is not available. After I add "System.ServiceModel" manually, those red lines disappear. But when I run it from Unity, I get the same error again. Also, when I restart Unity and go back to that script in Visual Studio, again I have to add "System.ServiceModel" manually.

希望您能理解我的意思.如何永久包含"System.ServiceModel"和"System.ServiceModel.Channels"?

I hope you understand what I mean.How can I permanently include "System.ServiceModel" and "System.ServiceModel.Channels"?

注意,我当前正在使用Visual Studio Pro和Unity Pro的试用版.这可能是个问题吗?

Note, I am currently using a trial version of Visual Studio Pro and Unity Pro. Could that be an issue?

推荐答案

谢谢!我只是将文件 System.ServiceModel.dll 复制到了新创建的Assets \ Plugin目录中.错误消失了:-).但是,我现在遇到另一个错误.

Thank you! I just copied the file System.ServiceModel.dll to my newly created Assets\Plugin directory. The error disappeared :-). However, I am having another error now.

使用以下命令,我想创建一个 NamedPipe 类型的代理.

With the following commands, I want to create a proxy of type NamedPipe.

ChannelFactory<ClassName> pipeFactory = new ChannelFactory<ClassName>(new NetNamedPipeBinding(),new EndpointAddress("net.pipe://localhost/PipeReverse"));               
ClassName pipeProxy = pipeFactory.CreateChannel();

运行代码时,出现以下错误:

When I run my code, I get the following error:

这篇关于找不到名称空间"ServiceModel";与Unity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 20:29