小编Phi*_*ray的帖子

RIA服务返回Silverlight POCO

我正在使用使用RIA服务的Silverlight 5业务应用程序从服务端返回POCO类以填充分层菜单.

我对POCO类的原始问题是SubMenuItems属性没有通过RIA服务传递,尽管它是在服务端填充的.

原创POCO

public class BusinessModelMenuDto
{
    [Key]
    [Required]
    public int ID { get; set; }
    public string TextToDisplay { get; set; }
    public string ImageSource { get; set; }
    public IEnumerable<BusinessModelMenuDto> SubMenuItems { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

服务电话

 public IEnumerable<BusinessModelMenuDto> GetCabsHeirarchy()
Run Code Online (Sandbox Code Playgroud)

经过一些进一步的调查后,我发现SubMenuItems需要[Include][Association]属性来传递数据.使用ID => ID关联第一次执行此操作时未提供所需结果,因此我添加了ParentID属性并更改了我的加载代码以填充外键,如下所示.我还将Associate更改为从ID映射到Parent ID.

更新了POCO课程

public class BusinessModelMenuDto
{
    [Key]
    [Required]
    public int ID { get; set; }
    public int? ParentID { get; set; }
    public string TextToDisplay { get; set; }
    public …
Run Code Online (Sandbox Code Playgroud)

.net c# silverlight wcf-ria-services silverlight-5.0

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

MEF导入在Windows服务中失败

我在Windows服务中的MEF组合中遇到了问题

以下类是继承自的部分类 System.ServiceProcess.ServiceBase

Imports System.ServiceProcess

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class svc_EpmsOPCService_6Cylinder_Zone1
    Inherits System.ServiceProcess.ServiceBase

    'UserService overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                If _catelog IsNot Nothing Then _catelog.Dispose()
                If _mefContainer IsNot Nothing Then _mefContainer.Dispose()
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    ' The main entry point for the process
    <MTAThread()> _
    Shared Sub Main()

#If Not Debug Then
        Dim ServicesToRun() As System.ServiceProcess.ServiceBase …
Run Code Online (Sandbox Code Playgroud)

.net vb.net mef visual-studio-2012

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

异步序列化操作中的 MissingMethodException

我已经从 NuGet 编写了一个Json.Net v5.06 的小型异步库包装器,在更新了许多 Telerik 包后,我的 UnitTests 开始失败并出现MissingMethodException

我创建了一个虚拟的非异步方法,该方法有效,所以我很困惑错误所在。

项目目标平台

.Net 4.5

x86CPU

异步操作

    public class JsonSerialiser : ISerialiser
    {

        [InjectionConstructor]
        public JsonSerialiser(IStringCompression streamCompressor, ILog logger)
        {
            if (streamCompressor == null) throw new ArgumentNullException("streamCompressor");
            if (logger == null) throw new ArgumentNullException("logger");

            XmlConfigurator.Configure();

            this.streamCompressor = streamCompressor;
            this.logger = logger;
        }


        public async Task<string> SerialiseAsync<T>(T serialseObject) where T : class
        {
            if (serialseObject == null) throw new ArgumentNullException("serialseObject");

            try
            {
                return await JsonConvert.SerializeObjectAsync(serialseObject);
            }
            catch (JsonSerializationException ex)
            {
                logger.Error(ex); …
Run Code Online (Sandbox Code Playgroud)

.net c# json.net async-await .net-4.5

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

Azure Functions 存储帐户网络安全

我目前正在与一个客户合作,该客户需要尽可能锁定所有 Azure 资源的访问权限,但我在使用 Azure Functions 的存储帐户时遇到了问题。

随着门户中的防火墙和虚拟网络刀片设置为“所有网络”,我能够部署到函数应用程序并且它运行没有问题。

在此处输入图片说明

但是,一旦我通过选中“选定的网络”启用访问限制,无论我输入什么虚拟网络子网或 IP 地址,我都无法使通信正常工作

在此处输入图片说明

我已经输入了我们基于消费的功能应用程序的出站 IP 地址,并检查了来自 Powershell 的其他 IP 地址和所有 IP 地址是否都已添加到白名单中。我还添加了本地 Azure 数据中心的所有 CIDR IP 范围,但它再次不起作用。

我们遇到的问题是,一旦设置了访问限制,我们就无法部署到 Function App 并且该应用程序不再运行。是否支持此方案以及绑定对存储帐户的访问权限以便只有功能应用程序可以使用它的机制是什么。

azure azure-storage azure-functions azure-security

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

条形码查找游戏,书籍,CD

我正在寻找自己的媒体库,并想知道有没有免费的.Net API来识别基于给定条形码的产品?作为次要点,有.Net API可以根据条形码返回书籍,CD,游戏等封面.

.net c# vb.net barcode

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

MVC4项目图像无法显示

我刚刚将我的第一个MVC4项目从我的开发机器部署到我的生产IIS7.5服务器,我遇到了一些问题,让图像在服务器上正确显示.

这可能是IIS7中的权限问题吗?

<input type="image" src="Content/Images/Product.png" runat="server" />
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

当我在桌面上运行时,图像显示正确,但是当我部署到服务器时,我得到标准的断开链接图像.我已确认图像在服务器上的路径正确.

我也尝试更改src以使用波形符,src="~/Content/Images/Product.png"但它仍然不起作用

这也开始影响site.css文件的加载

<head>
    <meta charset="utf-8" />
    <title>@ViewData("Title")</title>
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.6.2.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/modernizr-2.0.6-development-only.js")" type="text/javascript"></script>
</head>
Run Code Online (Sandbox Code Playgroud)

在Chrome中,我收到一条错误消息,说它未找到并且未在任何浏览中加载,但我已确认其在磁盘上. 在此输入图像描述

这里有些奇怪的事......

Web.Config中

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=152368
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
  </configSections>
  <appSettings>
    <add key="webpages:Version" value="1.0.0.0"/>
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" …
Run Code Online (Sandbox Code Playgroud)

html vb.net asp.net-mvc asp.net-mvc-4 visual-studio-2012

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

使用Linq过滤多级where子句

假设我有一些过滤条件通过CustomerFilter对象数组传递到我的应用程序中,我需要运行查询并根据从Linq到Entities查询的过滤器返回结果.

因此,在这种情况下,客户将通过服务调用将一组CustomerFilter对象传递给我.

过滤对象:

class CustomerFilter
{
    public string CustomerID;
    public int[] LocationID;
}
Run Code Online (Sandbox Code Playgroud)

示例数据:

CustomerID    LocationID 

1             1

              2

              3

              4 

2             2 

              3 


              4
Run Code Online (Sandbox Code Playgroud)

我可以很容易地在外部CustomerID上构建查询过滤,如下所示.

查询:

    public void GetCustomerResults(List<CustomerFilter> accounts)
    {
        List<string> customer = (from a in accounts select a.CustomerID).ToList();

        var locations = ctx.Portal_SurveyLocations
                            .Where(w => customer.Contains(w.CustNum))
                            .OrderBy(o => o.LocationKey);
    }
Run Code Online (Sandbox Code Playgroud)

所以我可以按外部标准进行筛选,但我不确定如何根据每个CustomerID的多个位置ID进行筛选.显然只是放置一个OR子句会产生不正确的结果,因为它会引入具有匹配LocationID的其他CustomerID.

在传入CustomerFilter对象的情况下,如何实现此多级过滤器的任何想法?

c# linq linq-to-entities

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

NUnit并测试Xamarin PCL

我正在开发一种便携式类库和iOS的应用,其中数据访问是基于顶部保罗贝茨 ModernHttpClient,齐射,改装Akavache库.这适用于PCL和iOS应用程序,但在针对PCL创建单元测试时遇到问题.

如果我使用在Visual Studio 2015中运行的Resharper测试,我的所有测试都会通过,但如果我在Xamarin Studio中运行NUnit测试,大约一半的测试会因TypeLoadExceptions而失败.我试图确定哪个dll导致我的问题,但据我所知,一切都是应有的.

正在测试的PCL类

   internal class ApiService<TRefitService> : IApiService<TRefitService> where TRefitService : IServiceContract
    {
        private readonly Lazy<TRefitService> background;
        private readonly Lazy<TRefitService> userInitiated;
        private readonly Lazy<TRefitService> speculative;

        private ApiService(){}

        public ApiService(string baseUrl)
        {
            ParameterGuard.ThrowIfNullOrEmpty(baseUrl, nameof(baseUrl));

            Func<string, RateLimitedHttpMessageHandler, TRefitService> createClient = (address, handler) =>
            {
                HttpClient client = new HttpClient(handler) {BaseAddress = new Uri(address)};
                return RestService.For<TRefitService>(client);
            };

            background = new Lazy<TRefitService>(() => createClient(baseUrl, new RateLimitedHttpMessageHandler(new NativeMessageHandler(), Priority.Background))); …
Run Code Online (Sandbox Code Playgroud)

c# mono unit-testing xamarin.ios xamarin

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

Xamarin - 在某些构建配置中包含设置包

我目前正在使用Xamarin构建一个iOS应用程序,并且正在寻求实现一个设置包,以便我们的QA部门可以将应用程序指向适当的API环境.

我正在做的是基于构建配置在Xamarin iOS应用程序中包含或排除Settings包,因为我可能不希望在Release模式下将此数据公开给用户.

您是否可以包含或排除"设置"捆绑包,甚至可以根据构建配置更改编译到应用程序中的捆绑包?

xamarin.ios ios settings.bundle xamarin

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

Blazer EditForm 提交不会触发 OnValidSubmit 和 OnInvalidSubmit 方法

我只是在摆弄我的第一个 Blazer 服务器应用程序,并且在提交 EditForm 时遇到了问题。验证适用于绑定到具有必需注释的属性的两个文本框,但当我提交表单时,不会调用任何表单方法,Chrome 只会报告错误。知道问题是什么吗?

@page "/"
@inject NavigationManager NavigationManager

@using MyModels

<div class="backgroupContainer">
    <EditForm Model="@authModel" OnValidSubmit="HandleValidSubmit" OnInvalidSubmit="HandleInValidSubmit">
        <DataAnnotationsValidator />

        <div id="login">
            <img id="login-image" src="images/img-01.png" alt="Login" />
            <div class="container">
                <div id="login-row" class="row justify-content-center align-items-center">
                    <div id="login-column" class="col-md-6">
                        <div id="login-box" class="col-md-12">
                            <form id="login-form" class="form" action="" method="post">
                                <h3 class="text-center text-info">Login</h3>
                                <div class="form-group">
                                    <label for="username" class="text-info">Username:</label><br>
                                    <InputText id="username" class="form-control" placeholder="Username" @bind-Value="authModel.Username" />
                                    <ValidationMessage For="@(() => authModel.Username)" />
                                </div>
                                <div class="form-group">
                                    <label for="password" class="text-info">Password:</label><br>
                                    <InputText id="password" class="form-control" type="password" placeholder="Password" @bind-Value="authModel.Password" />
                                    <ValidationMessage …
Run Code Online (Sandbox Code Playgroud)

blazor blazor-server-side

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