小编BBa*_*r42的帖子

无法预览VS2013中的SSRS报告?

我在VS2013 .Net 4.5中创建了一个新的"Report Server Project".我添加了一个数据源,测试连接成功.我使用"使用我的报表中嵌入的数据集"选项添加了一个DataSet,选择了之前创建的数据源.查询类型是带有单个文本参数的存储过程.在报告数据框中,我可以右键单击我的DataSet,选择Query,然后执行sproc.我看到网格正确填充了我的数据.

但是,当我尝试创建和预览报表时,它会失败.我做以下事情:

  1. 添加新报告.
  2. 从工具箱中删除表格.
  3. 开始将我的DataSet中的字段拖到表上.
  4. 当我点击预览时,我看到以下内容 在此输入图像描述

这是在输出窗口中吐出的文本:

System.ServiceModel.CommunicationObjectFaultedException:通信对象System.ServiceModel.Channels.ClientFramingDuplexSessionChannel不能用于通信,因为它处于Faulted状态.

服务器堆栈跟踪:位于System.ServiceModel.Dseput上的System.ServiceModel.Channels.CommunicationObject.ThrowIfDisposedOrNotOpen()处于System.ServiceModel.Depatcher.DuplexChannelBinder.BeginRequest的消息消息,消息消息,TimeSpan超时,AsyncCallback回调,对象状态.系统中的System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.StartSend(Boolean completedSynchronously)处的System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.FinishEnsureOpen(IAsyncResult result,Boolean completedSynchronously)上的消息消息,TimeSpan超时,AsyncCallback回调,对象状态. System.ServiceModel上的System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.FinishEnsureInteractiveInit(IAsyncResult result,Boolean completedSynchronously)Service.ServiceModel上的System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.StartEnsureInteractiveInit()中的ServiceModel.Channels.ServiceChannel.SendAsyncResult.StartEnsureOpen(Boolean completedSynchronously) .Channels.ServiceChannel.SendAsyncResult.Begin()在System.ServiceModel.Channels.ServiceChannel.BeginCall(String action,Boolean oneway,ProxyOperationRuntime operation,Object [] ins,TimeSpan timeout,AsyncCallback callback,Object asyncState)System.ServiceModel.Channels.ServiceChannelProxy.InvokeBeginService( System.ServiceModel.Channels.ServiceChannelProxy.Invoke中的IMethodCallMessage methodCall,ProxyOperationRuntime操作(IMessage消息)

在[0]处重新抛出异常:位于Microsoft.ReportDesigner的System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&msgData,Int32类型)的System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg). Microsoft.ReportDesigner.Design.WCFProcessingHost.<> c__DisplayClass1.b__0上的Microsoft.ReportDesigner.Design.PreviewProcessingClient.BeginSetItemPath(String itemPath,AsyncCallback callback,Object asyncState)的Design.IPreviewProcessing.BeginSetItemPath(String itemPath,AsyncCallback callback,Object asyncState). AsyncCallback ac,Object s)在Microsoft.ReportDesigner.Design.WCFProcessingHost.ExecuteAsyncCall(Func`3)的Microsoft.ReportDesigner.Design.WCFProcessingHost.ExecuteWcfCall(Action wcfCall)上的Microsoft.ReportDesigner.Design.WCFProcessingHost.<> c__DisplayClass3b.b__39() Microsoft.ports.WinForms.Lo上的Microsoft.ReportDesigner.Design.WCFProcessingHost.set_ItemContext(PreviewItemContext值)的beginAction,AsyncCallback endAction)Microsoft.ReportDesigner.Design.PreviewFrame.RefreshPreview()上的Microsoft.Reporting.WinForms.LocalReport.set_ReportPath(String value)中的calReport.ChangeReportDefinition(DefinitionSource updatesSourceType,Action changeAction).

我用谷歌搜索了两天没有运气,任何帮助都非常感谢.


编辑: 事实证明,当您预览报表时,此控制台窗口将打开.我必须在第一次关闭它,然后预览失败.如果您打开控制台窗口,预览工作正常.这是一个截图,你可以看到我在说什么.为了让预览工作,我只需要重新启动visual studio,并确保在我点击预览时弹出它时不要关闭控制台窗口.

在此输入图像描述

reporting-services

5
推荐指数
1
解决办法
4318
查看次数

在急切加载时,您可以在EF中排除反向导航属性吗?

当我在EF6中使用.Include语法时,始终会加载反向导航属性.有没有办法把它关掉?这是一个示例查询.

private static IQueryable<Account> GetAccountsEager(this IRepository<Account> repository)
{
    return repository
        .Queryable()
        .Include(e => e.AccountLocations
            .Select(l => l.Address.City.State.Country));
}
Run Code Online (Sandbox Code Playgroud)

这给了我帐户的AccountLocations集合.但是,地址'城市上有这个反向导航属性:

public virtual ICollection<Address> Addresses { get; set; }
Run Code Online (Sandbox Code Playgroud)

..然后它重新加载所有反向导航地址,以便在查询中提供比我想要的更多的数据.我可以以某种方式关闭反向导航吗?

我只是从实体中删除反向导航属性,但在其他情况下,我实际上想要向后看以从城市获取地址.

谢谢.


编辑1:
我刚才注意到一些奇怪的东西.这不会加载城市的反向导航地址:

return repository.Queryable()
    .Include(e => e.BillToAddress.AddressType)
    .Include(e => e.BillToAddress.City.State.Country);
Run Code Online (Sandbox Code Playgroud)

但是,如果我添加这样的包含:

return repository.Queryable()
    .Include(e => e.BillToAddress.AddressType)
    .Include(e => e.BillToAddress.City.State.Country);
    .Include(e => e.AccountLocations.Select(a => a.Address.City.State.Country));
Run Code Online (Sandbox Code Playgroud)

然后为e.BillToAddress.City和每个AccountLocation的Address.City加载反向导航地址.为什么添加.Select在第三个包括影响第二个包含?

这是SQL:

exec sp_executesql N'SELECT 
    //removing [ProjectX].[Property] AS [Property] for brevity
    //essentially a line for each property of the syntax above...
    FROM ( SELECT 
        [Limit1].[AccountId] AS …
Run Code Online (Sandbox Code Playgroud)

entity-framework navigation-properties

5
推荐指数
1
解决办法
1657
查看次数

Unity和Simple Injector之间的IoC注册差异

我有一个项目使用Unity完美运行.我尝试切换到使用Simple Injector,现在没有任何更改保存在我的数据库中.我认为这与注册组件的生命周期有关.这是Unity容器注册:

private IUnityContainer GetUnityContainer()
{
    IUnityContainer container = new UnityContainer()
        .RegisterType<IDatabaseFactory, DatabaseFactory>(
            new HttpContextLifetimeManager<IDatabaseFactory>())
    .RegisterType<IUnitOfWork, UnitOfWork>(
        new HttpContextLifetimeManager<IUnitOfWork>())
    .RegisterType<ICategoryRepository, CategoryRepository>(
        new HttpContextLifetimeManager<ICategoryRepository>())
    .RegisterType<ICategoryService, CategoryService>(
        new HttpContextLifetimeManager<ICategoryService>());

    return container;         
}
Run Code Online (Sandbox Code Playgroud)

这是新的Simple Injector注册.

container.Register<IDatabaseFactory, DatabaseFactory>();
container.Register<IUnitOfWork, UnitOfWork>();
container.Register<ICategoryRepository, CategoryRepository>();
container.Register<ICategoryService, CategoryService>();
Run Code Online (Sandbox Code Playgroud)

我不确定HttpContextLifetimeManagerSimple Injector 是如何发挥作用的.MVC是统一示例的客户端,但我正在改为WPF项目和Simple Injector.任何建议都非常感谢.谢谢.


@Steven.谢谢你的评论.我刚刚发现,因为我的RepositoryBase和我的UnitOfWork在我需要使用的构造函数中注入了一个IDatabaseFactory container.RegisterSingle<IDatabaseFactory, DatabaseFactory>().这解决了一个问题.我的生命仍然有问题.由于我的消费应用程序是WPF,RegisterPerWebRequest将如何工作?

我的项目有一个DataLayer >> BusinessLayer >> WcfService >> WPF前端.简单的Injector在WcfService项目上设置,业务层有Boostrapper在那里注册项目.截至目前,我的WPF客户端将GetAllCountries()并显示在网格中.如果我更改了一个名称并尝试更新,我会得到"ObjectStateManager中已存在具有相同键的对象.ObjectStateManager无法跟踪具有相同键的多个对象." 错误.我做了一些调试,发现在WPF客户端中调用GetCountries服务之后,当我回去尝试更新时,我看到所有国家都通过dbContext.ChangeTracker.Entries()附加到上下文.此时我应该没有跟踪任何实体,因为我的上下文应该在第一个工作单元之后被处理掉.

在一个MVC应用程序中,RegisterPerWebRequest修复了这个问题,但WPF的等价物是什么?我现在要安装扩展程序并尝试它但我觉得这不是我正在寻找的解决方案..或者是它?再次感谢您的帮助.


好.我做了一些挖掘,找到了一个有效的解决方案.我只是不确定它是不是正确的.无论如何,现在在我的BLL中有一个注册东西的引导程序,我可以像这样注册:

container.RegisterPerWcfOperation<IDatabaseFactory, DatabaseFactory>();
container.RegisterPerWcfOperation<IUnitOfWork, UnitOfWork>();
container.RegisterPerWcfOperation<ICountryRepository, CountryRepository>();
Run Code Online (Sandbox Code Playgroud)

这给了我正在寻找的东西.只创建了一个DatabaseFactory实例,因此我的存储库和工作单元就像它们应该的那样共享它.此外,在客户端上的GetCountries()之后,当我第二次调用服务执行和更新时,我检查dbContext.ChangeTracker.Entries()并查看没有跟踪的实体,这是正确的.我现在可以附加,设置修改,并调用SaveChanges而不会出现重复键错误.这看起来好吗?谢谢.

.net c# dependency-injection inversion-of-control simple-injector

4
推荐指数
1
解决办法
3956
查看次数

WCF 激活功能的用途是什么?

我在 Visual Studio 2013 中创建 WCF 服务并将其发布到 IIS。我可以在另一个项目中添加服务引用并使用该服务的方法。当我转到 IIS 服务器管理器时,我看到 WCF 激活及其两个子项(HTTP 激活和非 HTTP 激活)未选中。

这些功能是什么?如果不启用这些功能,我的 WCF 站点如何工作?我在网上浏览了很多,但没有找到任何明确的答案。谢谢。

wcf

4
推荐指数
1
解决办法
9524
查看次数

如何使用AutoMapper将DataRow映射到WCF服务中的对象?

我有一个WCF服务,它调用存储过程并返回一个DataTable.我想在发送给消费者之前将DataRows转换为自定义对象,但无法弄清楚如何这样做.假设我从存储过程中检索了一个客户.通过DataRow,客户可以做到这一点:

string lastName = dt.Rows[0]["LastName"].ToString();
string firstName = dt.Rows[0]["FirstName"].ToString();
string age = System.Convert.ToInt32(dt.Rows[0]["Age"].ToString());
Run Code Online (Sandbox Code Playgroud)

我可以轻松找回客户.现在,我创建了一个Customer对象,如下所示:

public Customer
{
     public string LastName {get;set;}
     public string FirstName {get;set;}
     public int Age {get;set;}
}
Run Code Online (Sandbox Code Playgroud)

我从包管理器控制台加载了AutoMapper.然后,我将一个公共静态方法放在我的客户上,如下所示:

public static Customer Get(DataRow dr)
{
     Mapper.CreateMap<DataRow, Customer>();
     return Mapper.Map<DataRow, Customer>(dr);
}
Run Code Online (Sandbox Code Playgroud)

当我单步执行代码时,从Get()返回的客户中的每个属性都为null.我在这里错过了什么?我是否必须添加自定义扩展以从DataRow映射?这是一个似乎相关线程,但我认为AutoMapper会支持这种开箱即用,特别是因为属性名称与列名相同.提前致谢.

automapper

2
推荐指数
1
解决办法
5137
查看次数

将SSIS包作为SQL Server代理作业运行不会复制文件?

我有一个SSIS包,我可以导入我的服务器上的Integration Services并运行没有问题.它所做的就是将文件从网络上的目录复制到运行它的服务器上.

当我执行SQL代理作业时,它表示作业成功运行但没有复制文件.我验证源位置中存在文件并且目标路径存在.我也使用绝对路径(没有映射驱动器).

当我将其作为SQL代理作业运行时,为什么不复制任何文件?

仅供参考 - 源目录实际上位于UNIX机器上,要将驱动器映射到该位置,您必须输入用户/密码组合.

我感觉SQL代理作业运行为NT SERVICE\SQLSERVERAGENT,它不是具有UNIX框权限的用户.有没有办法以特定用户身份运行SQL作业?

提前致谢.

ssis

2
推荐指数
1
解决办法
3570
查看次数

如何使用Autofac与WCF无文件激活和自定义ServiceHostFactory?

我需要在我的CusotmServiceHostFactory中添加绑定/配置.但是,我想使用Autofac.我的CustomServiceHostFacotry如何实现AutofacServiceHostFactory?我正在使用无文件激活,所以我的配置部分如下所示:

<serviceActivations>                
  <add service="Project.Business.Services.AccountService" 
        relativeAddress="Account/AccountService.svc" 
        factory="Project.WebHost.CustomServiceHostFactory"/>
</serviceActivations>
Run Code Online (Sandbox Code Playgroud)

这是我目前的定制工厂:

public class CustomServiceHostFactory : ServiceHostFactory
{
    protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
    {
        var builder = new ContainerBuilder();
        builder.RegisterType<MyDbContext>().As<IDataContextAsync>();
        builder.RegisterType<UnitOfWork>().As<IUnitOfWorkAsync>();

        builder.RegisterGeneric(typeof (Repository<>)).As(typeof (IRepositoryAsync<>));

        builder.RegisterAssemblyTypes(typeof(AccountService).Assembly)
            .Where(t => t.Name.EndsWith("Service"))
            .As(t => t.GetInterfaces().FirstOrDefault(
                i => i.Name == "I" + t.Name));

        var container = builder.Build();
        var host = new CustomServiceHost(serviceType, baseAddresses);
        Type contractType = GetContractType(serviceType);
        host.AddDependencyInjectionBehavior(contractType, container);

        return host;
    }
    private static Type GetContractType(Type serviceType)
    {
        return serviceType.GetInterfaces()
            .FirstOrDefault(i => Attribute.IsDefined(i, typeof(ServiceContractAttribute), false));
    }
} …
Run Code Online (Sandbox Code Playgroud)

wcf dependency-injection autofac

1
推荐指数
1
解决办法
1596
查看次数

Asp.net Identity 2 User.Identity.GetUserId <int>()总是返回0?

我已经扩展了Asp.net Identity 2模型,通过跟随这样这样的帖子来使用整数键.但是,这行代码始终返回0.

User.Identity.GetUserId<int>()
Run Code Online (Sandbox Code Playgroud)

即使User.Identity.IsAuthenticated为true且User.Identity.GetUserName()返回正确的用户名.我已经看过这篇文章,但它没有帮助,因为我已经在控制器方法中调用User.Identity.GetUserId()而不是构造函数.该帖子中对"getUserIdCallback"的引用很有意思,也许我需要这样的东西.任何帮助深表感谢.

asp.net-identity-2

1
推荐指数
1
解决办法
1498
查看次数