,我发现了以下错误在我的WCF项目:误差WCF
“‘System.InvalidOperationException’类型的未处理的异常出现在System.ServiceModel.dll
更多信息:找不到在ServiceModel客户端配置部分中引用合同'IPhiFeed'的默认端点元素,这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到匹配此合同的端点元素。
WCF项目有点实验:是托管和非托管C++和C#的混合。我已经掌握了所有使用纯C#的工作,但是我必须从非托管C++中使用WCF,因此需要在WCF中编写C++包装器。
更新
按照要求,这里是代码多数民众赞成抛出该异常:
// WCF library written in C#
public class EngineAPI : IEngineAPI
{
public FeedClient client;
// constructor
public EngineAPI()
{
// the line below in this C# library works *perfectly* when called from a C#
// console app, but it fails when a C++ console app calls the same C# library
// UPDATE: exception fixed if you copy app.config to out.exe.config, see comments below
client = new FeedClient(); // << exception here
}
.....
}
// NOTE: the line "client = new FeedClient" instantiates generatedProxy.cs,
// which is generated with svcutil
// NOTE: if I temporarily delete "app.config" from the pure C# project, it generates *exactly* the same error as I'm getting when I attempt to call everything from the separate C++ project with managed code.
更新
发现了问题,这是无关的代码:你有将app.config复制到out.exe.config。我现在有一个100%正常工作的C++/CLI项目,调用一个使用WCF的C#库。看到我的评论如下。
生成错误的代码将会有所帮助。否则,答案可能太模糊,无法帮助。 – 2010-10-05 14:13:46
好点。我用有问题的代码更新了它。 – Contango 2010-10-05 23:22:30