Sequence不包含任何元素,Castle.Facilities.WcfIntegration.WcfClientExtension.ObtainServiceContract

时间:2014-10-09 15:46:19

标签: c# wpf web-services castle-windsor caliburn.micro

我在.NET4.5 WPF应用程序中工作。我在App.xml <desktop1:ReactiveBootstrapper x:Key="bootstrapper" />上显示了一个特殊的异常,我认为这与添加新的网络服务方法有关。

app.xml的

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary>
                <desktop1:ReactiveBootstrapper x:Key="bootstrapper" />
            </ResourceDictionary>
            <ResourceDictionary Source="Utilities/Styles/DefaultStyle.xaml" />
            <ResourceDictionary Source="Utilities/Styles/DataGridStyle.xaml" />
            <!--<ResourceDictionary Source="Utilities/Styles/ScrollViewerStyle.xaml"/>-->
            <ResourceDictionary Source="Utilities/Styles/RoundedButtonStyle.xaml" />
            <ResourceDictionary Source="Utilities/Styles/ExpanderStyle.xaml" />
            <ResourceDictionary Source="Utilities/Styles/RadioButtonStyle.xaml" />
            <!--<ResourceDictionary Source="Utilities/Styles/DropDownStyle.xaml"/>-->
        </ResourceDictionary.MergedDictionaries>
        <BooleanToVisibilityConverter x:Key="boolToVis" />
        <iValueConverters:BooleanToVisibilityConverter x:Key="negatedBoolToVis" True="Collapsed" False="Visible" />
        <iValueConverters:NullToVisibilityConverter x:Key="nullToVis" VisibleWhenNull="True" />
        <valueConverters1:NotNullToVisibilityConverter x:Key="notNullToVis" VisibleWhenNotNull="True" />
        <valueConverters1:NotNullToCollapsedVisibilityConverter x:Key="notNullToCollapsedVis"
                                                                VisibleWhenNotNull="True" />
        <valueConverters1:EnvironmentToBooleanConverter x:Key="EnvironmentToBooleanConverter" />
    </ResourceDictionary>
</Application.Resources>

堆栈追踪:

   at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
   at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
   at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
   at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
   at Corp.Desktop.App.InitializeComponent() in c:\dev\CCTech Main\Corp-Wills\Corp.Conveyancing.Desktop\App.xaml:line 1
   at Corp.Desktop.App.Main() in c:\dev\CCTech Main\Corp-Wills\Corp.Conveyancing.Desktop\obj\x86\Debug\App.g.cs:line 0
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

inner stackTrace:

   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
   at Castle.Facilities.WcfIntegration.WcfClientExtension.ObtainServiceContract(ComponentModel model, IWcfClientModel clientModel) in d:\work\8dfeb153df23a288\src\Castle.Facilities.WcfIntegration\Client\WcfClientExtension.cs:line 239
   at Castle.Facilities.WcfIntegration.WcfClientExtension.ResolveClientModel(ComponentModel model) in d:\work\8dfeb153df23a288\src\Castle.Facilities.WcfIntegration\Client\WcfClientExtension.cs:line 231
   at Castle.Facilities.WcfIntegration.WcfClientExtension.Kernel_ComponentModelCreated(ComponentModel model) in d:\work\8dfeb153df23a288\src\Castle.Facilities.WcfIntegration\Client\WcfClientExtension.cs:line 189
   at Castle.MicroKernel.ComponentModelDelegate.Invoke(ComponentModel model)
   at Castle.MicroKernel.DefaultKernel.RaiseComponentModelCreated(ComponentModel model) in d:\work\8dfeb153df23a288\src\Castle.Windsor\MicroKernel\DefaultKernel_Events.cs:line 72
   at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.CreateHandler(ComponentModel model) in d:\work\8dfeb153df23a288\src\Castle.Windsor\MicroKernel\DefaultKernel.cs:line 273
   at Castle.MicroKernel.DefaultKernel.AddCustomComponent(ComponentModel model) in d:\work\8dfeb153df23a288\src\Castle.Windsor\MicroKernel\DefaultKernel.cs:line 260
   at Castle.MicroKernel.Registration.ComponentRegistration`1.Castle.MicroKernel.Registration.IRegistration.Register(IKernelInternal kernel) in d:\work\8dfeb153df23a288\src\Castle.Windsor\MicroKernel\Registration\ComponentRegistration.cs:line 1122
   at Castle.MicroKernel.DefaultKernel.Register(IRegistration[] registrations) in d:\work\8dfeb153df23a288\src\Castle.Windsor\MicroKernel\DefaultKernel.cs:line 501
   at Castle.MicroKernel.Registration.BasedOnDescriptor.TryRegister(Type type, IKernel kernel) in d:\work\8dfeb153df23a288\src\Castle.Windsor\MicroKernel\Registration\BasedOnDescriptor.cs:line 512
   at Castle.MicroKernel.Registration.FromDescriptor.Castle.MicroKernel.Registration.IRegistration.Register(IKernelInternal kernel) in d:\work\8dfeb153df23a288\src\Castle.Windsor\MicroKernel\Registration\FromDescriptor.cs:line 184
   at Castle.MicroKernel.Registration.BasedOnDescriptor.Castle.MicroKernel.Registration.IRegistration.Register(IKernelInternal kernel) in d:\work\8dfeb153df23a288\src\Castle.Windsor\MicroKernel\Registration\BasedOnDescriptor.cs:line 558
   at Castle.MicroKernel.DefaultKernel.Register(IRegistration[] registrations) in d:\work\8dfeb153df23a288\src\Castle.Windsor\MicroKernel\DefaultKernel.cs:line 501
   at Castle.Windsor.WindsorContainer.Register(IRegistration[] registrations) in d:\work\8dfeb153df23a288\src\Castle.Windsor\Windsor\WindsorContainer.cs:line 483
   at Corp.Desktop.ReactiveBootstrapper.RegisterWcfServices() in c:\dev\CCTech Main\Corp-Wills\Corp.Conveyancing.Desktop\ReactiveBootstrapper.cs:line 101
   at Corp.Desktop.ReactiveBootstrapper.Configure() in c:\dev\CCTech Main\Corp-Wills\Corp.Conveyancing.Desktop\ReactiveBootstrapper.cs:line 146
   at Caliburn.Micro.BootstrapperBase.StartRuntime() in c:\Projects\caliburnmicro\src\Caliburn.Micro.Silverlight\Bootstrapper.cs:line 98
   at Caliburn.Micro.BootstrapperBase.Start() in c:\Projects\caliburnmicro\src\Caliburn.Micro.Silverlight\Bootstrapper.cs:line 49
   at Corp.Desktop.ReactiveBootstrapper..ctor() in c:\dev\CCTech Main\Corp-Wills\Corp.Conveyancing.Desktop\ReactiveBootstrapper.cs:line 66

它在this.Start();上的Reactive bootstrapper构造函数中爆炸了。我无法继续介入。

 public class ReactiveBootstrapper : BootstrapperBase {
 public ReactiveBootstrapper()
    {
        this.Log.Info("Starting bootstrapper");
        this.Start();
    }
}

BootstrapperBase来自Caliburn.Micro我假设某些内容因依赖注入而爆炸。

你们之前是否有人偶然发现了这个错误并知道这里发生了什么?或者有进一步调试的想法吗?,我认为在向Web服务添加其他方法后异常开始出现,但我并非100%肯定。如果您需要更多信息,请询问。

1 个答案:

答案 0 :(得分:0)

原来,我将没有支持Web服务的Interface添加到“错误”文件夹中,其中保存了所有Web服务接口。

public static void RegisterWcfServices()
  {
        Container.Register(
            Types.FromAssemblyContaining<ITransactionService>()
                .InSameNamespaceAs<ITransactionService>()
                .Configure(
                    x =>
                    x.Named(x.Implementation.Name)
                        .AsWcfClient(
                            new DefaultClientModel
                                {
                                    Endpoint =
                                        WcfEndpoint.BoundTo(new WSHttpBinding(SecurityMode.Transport) { MaxReceivedMessageSize = int.MaxValue })
                                        .At(string.Format("https://{0}/{1}.svc", GetServerName(), x.Name.Substring(1)))
                                })
                        .IsFallback()));
    }
上面的

机制拿起了接口,因为没有WebService支持,它就爆炸了。