I've got a Client/Server wcf application
我有一个客户端/服务器wcf应用程序
My executable doesn't define any ServiceContract
, it doesn't even have a reference to System.ServiceModel
(but instead has a reference to an assembly which contains the connection logic to the server)
我的可执行文件没有定义任何ServiceContract,它甚至没有对系统的引用。ServiceModel(而是引用一个包含到服务器的连接逻辑的程序集)
I've another assembly, which is referenced by my EXE, which contains a ServiceContract
.
我有另一个程序集,它由我的EXE引用,它包含一个ServiceContract。
It used to work fine. Yesterday, I've played a lot with my project settings (partial trust, full trust, deployment settings, and so on) and now, each and every time I launch my client, I've got the following message box :
它以前工作得很好。昨天,我在我的项目设置(部分信任、完全信任、部署设置等等)上做了很多尝试,现在,每次我启动我的客户端时,我都会得到以下消息框:
Microsoft WCF Service Host
The target assembly contains no service types.
You may need to adjust the Code Access Security policy of this assembly.Microsoft WCF服务主机,目标程序集不包含任何服务类型。您可能需要调整这个程序集的代码访问安全策略。
Then VS freezes for 1 minute, and eventually lets me debug my program as usual.
然后VS冻结1分钟,并最终让我像往常一样调试我的程序。
I've found a post on this problem, but the solution doesn't apply in my situation. Any ideas?
我找到了一个关于这个问题的帖子,但是这个解决方案并不适用于我的情况。什么好主意吗?
8 个解决方案
#1
111
It's always like that. You search for 2 hours, you eventually end up posting on SO, and 5 minutes later, you find the answer.
它总是这样。你搜索了2个小时,最终你在SO上发布了,5分钟后,你找到了答案。
In the WCF Options tab of the properties of the project defining the ServiceContract
, there's a checkbox labelled "Start WCF Service Host when debugging another project in the same solution" that I unchecked.
在定义ServiceContract属性的项目的WCF Options选项卡中,有一个复选框,标记为“在同一解决方案中调试另一个项目时启动WCF服务主机”(我未检查)。
I've no idea how it has been checked in the first place.
我不知道它是怎么被检查的。
Anyway, that solved my problem. See the MSDN Reference for this project setting.
不管怎样,这解决了我的问题。参见此项目设置的MSDN引用。
#2
10
Just in case anyone else is looking for an answer, another cause of this error can be if you happen to have an App.config
file in a project that is a Class Library that has a <system.serviceModel>
section.
为了防止其他人正在寻找答案,如果您碰巧在项目中有一个application .config文件,而这个项目是一个具有
I moved service code out of a project that was an executable to a different project but accidentally left the old App.config
file. My new project, which was a Console application programatically configured and started WCF, but because the old App.config
file was in the referenced assembly, I would get that cryptic dialog box even when debugging the Console application.
我将服务代码从一个可执行到另一个项目的项目中移出,但不小心漏掉了旧的App.config文件。我的新项目是一个控制台应用程序,它以编程方式配置并启动了WCF,但是因为旧的App.config文件是在引用的程序集中,所以即使调试控制台应用程序,我也会得到那个隐藏的对话框。
Took about 12 hours to track this one down since I didn't realize that VS debugger checks all referenced assemblies for App.config which have WCF services configured.
我花了大约12个小时来跟踪这个程序,因为我没有意识到VS调试器检查配置了WCF服务的App.config的所有引用程序集。
#3
7
To determine project with this problem find string 3D9AD99F-2412-4246-B90B-4EAA41C64699 in your project files.
要确定这个问题,请在您的项目文件中找到字符串3d9ad99f -2412-4246- b90b - 4a41c64699。
Example: <ProjectTypeGuids>{3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
例子:< ProjectTypeGuids > { 3 d9ad99f - 2412 - 4246 - b90b - 4 - eaa41c64699 },{ fae04ec0 - 301 f - 11 - d3 - bf4b - 00 - c04f79efbc } < / ProjectTypeGuids >
Then turn off project option "WCF Options/Start WCF Service Host when debugging another project in the same solution"
然后关闭项目选项“WCF选项/在同一解决方案中调试另一个项目时启动WCF服务主机”
#4
4
Some blogs say, it might have happend because of copying the project from a different branch, that overrides GUIDs... so just delete them as explained in this blog.
有些博客说,这可能是由于从另一个分支复制项目而发生的,该分支覆盖了gui……所以就像这个博客里解释的那样删掉它们。
#5
1
This error can also be caused by a wrong service name in your config file:
这个错误也可以由配置文件中的错误服务名引起:
<system.serviceModel>
<services>
<service name="MyServiceLibrary.WrongServiceName">
...
Check your config file and be sure the service name is correct.
检查配置文件,确保服务名称正确。
#6
1
Old thread. Just remove any commandline arguments from the Debug section in Options. That helped me.
旧的线程。只需在选项中从Debug部分删除命令行参数。这帮助了我。
#7
1
I also went through the same kind of problem and searched for hours to get rid of this particular error. Finally i did find out a way out of it.
我也经历了同样的问题,搜索了几个小时来摆脱这个特殊的错误。最后,我找到了一条出路。
When you come across this particular problem, you try to run your both server and client application as administrator, and change the WPF properties of project.
当遇到这个问题时,您尝试以管理员的身份运行服务器和客户机应用程序,并更改项目的WPF属性。
When you click the WPF properties of the project, you will find a build option. In build option, there is a option called PLATFORM TARGET, in which you can change the platform target to x86. Also note that in case of x84, you need to set it to x84.
当您单击项目的WPF属性时,您将找到一个构建选项。在build选项中,有一个名为PLATFORM TARGET的选项,您可以在其中将平台目标更改为x86。还要注意,对于x84,需要将其设置为x84。
Now run your project from console, i.e. go to the folder where your projects are saved and in the bin of client, you will find a folder debug where you will get your console application. You should now be able to run the application successfully.
现在从控制台运行您的项目,例如,到保存项目的文件夹,在客户端文件夹中,您将找到一个文件夹debug,您将在其中获得控制台应用程序。现在您应该能够成功地运行应用程序了。
#8
0
Adding another solution since this message seems to have multiple causes. Removing the following GUID from the ProjectTypeGuids tag in the project file resolved the issue.
添加另一个解决方案,因为这个消息似乎有多个原因。从项目文件中的ProjectTypeGuids标签中删除下面的GUID解决了这个问题。
<ProjectTypeGuids>{3D9AD99F-2412-4246-B90B-4EAA41C64699}</ProjectTypeGuids>
#1
111
It's always like that. You search for 2 hours, you eventually end up posting on SO, and 5 minutes later, you find the answer.
它总是这样。你搜索了2个小时,最终你在SO上发布了,5分钟后,你找到了答案。
In the WCF Options tab of the properties of the project defining the ServiceContract
, there's a checkbox labelled "Start WCF Service Host when debugging another project in the same solution" that I unchecked.
在定义ServiceContract属性的项目的WCF Options选项卡中,有一个复选框,标记为“在同一解决方案中调试另一个项目时启动WCF服务主机”(我未检查)。
I've no idea how it has been checked in the first place.
我不知道它是怎么被检查的。
Anyway, that solved my problem. See the MSDN Reference for this project setting.
不管怎样,这解决了我的问题。参见此项目设置的MSDN引用。
#2
10
Just in case anyone else is looking for an answer, another cause of this error can be if you happen to have an App.config
file in a project that is a Class Library that has a <system.serviceModel>
section.
为了防止其他人正在寻找答案,如果您碰巧在项目中有一个application .config文件,而这个项目是一个具有
I moved service code out of a project that was an executable to a different project but accidentally left the old App.config
file. My new project, which was a Console application programatically configured and started WCF, but because the old App.config
file was in the referenced assembly, I would get that cryptic dialog box even when debugging the Console application.
我将服务代码从一个可执行到另一个项目的项目中移出,但不小心漏掉了旧的App.config文件。我的新项目是一个控制台应用程序,它以编程方式配置并启动了WCF,但是因为旧的App.config文件是在引用的程序集中,所以即使调试控制台应用程序,我也会得到那个隐藏的对话框。
Took about 12 hours to track this one down since I didn't realize that VS debugger checks all referenced assemblies for App.config which have WCF services configured.
我花了大约12个小时来跟踪这个程序,因为我没有意识到VS调试器检查配置了WCF服务的App.config的所有引用程序集。
#3
7
To determine project with this problem find string 3D9AD99F-2412-4246-B90B-4EAA41C64699 in your project files.
要确定这个问题,请在您的项目文件中找到字符串3d9ad99f -2412-4246- b90b - 4a41c64699。
Example: <ProjectTypeGuids>{3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
例子:< ProjectTypeGuids > { 3 d9ad99f - 2412 - 4246 - b90b - 4 - eaa41c64699 },{ fae04ec0 - 301 f - 11 - d3 - bf4b - 00 - c04f79efbc } < / ProjectTypeGuids >
Then turn off project option "WCF Options/Start WCF Service Host when debugging another project in the same solution"
然后关闭项目选项“WCF选项/在同一解决方案中调试另一个项目时启动WCF服务主机”
#4
4
Some blogs say, it might have happend because of copying the project from a different branch, that overrides GUIDs... so just delete them as explained in this blog.
有些博客说,这可能是由于从另一个分支复制项目而发生的,该分支覆盖了gui……所以就像这个博客里解释的那样删掉它们。
#5
1
This error can also be caused by a wrong service name in your config file:
这个错误也可以由配置文件中的错误服务名引起:
<system.serviceModel>
<services>
<service name="MyServiceLibrary.WrongServiceName">
...
Check your config file and be sure the service name is correct.
检查配置文件,确保服务名称正确。
#6
1
Old thread. Just remove any commandline arguments from the Debug section in Options. That helped me.
旧的线程。只需在选项中从Debug部分删除命令行参数。这帮助了我。
#7
1
I also went through the same kind of problem and searched for hours to get rid of this particular error. Finally i did find out a way out of it.
我也经历了同样的问题,搜索了几个小时来摆脱这个特殊的错误。最后,我找到了一条出路。
When you come across this particular problem, you try to run your both server and client application as administrator, and change the WPF properties of project.
当遇到这个问题时,您尝试以管理员的身份运行服务器和客户机应用程序,并更改项目的WPF属性。
When you click the WPF properties of the project, you will find a build option. In build option, there is a option called PLATFORM TARGET, in which you can change the platform target to x86. Also note that in case of x84, you need to set it to x84.
当您单击项目的WPF属性时,您将找到一个构建选项。在build选项中,有一个名为PLATFORM TARGET的选项,您可以在其中将平台目标更改为x86。还要注意,对于x84,需要将其设置为x84。
Now run your project from console, i.e. go to the folder where your projects are saved and in the bin of client, you will find a folder debug where you will get your console application. You should now be able to run the application successfully.
现在从控制台运行您的项目,例如,到保存项目的文件夹,在客户端文件夹中,您将找到一个文件夹debug,您将在其中获得控制台应用程序。现在您应该能够成功地运行应用程序了。
#8
0
Adding another solution since this message seems to have multiple causes. Removing the following GUID from the ProjectTypeGuids tag in the project file resolved the issue.
添加另一个解决方案,因为这个消息似乎有多个原因。从项目文件中的ProjectTypeGuids标签中删除下面的GUID解决了这个问题。
<ProjectTypeGuids>{3D9AD99F-2412-4246-B90B-4EAA41C64699}</ProjectTypeGuids>