小编gen*_*ser的帖子

反序列化枚举

我有一个xml,其中一个元素的属性可以为空.例如,

<tests>
<test language="">
.....
</test>
</tests>
Run Code Online (Sandbox Code Playgroud)

现在,语言是从模式创建的类中的枚举类型.如果指定了语言,它可以正常工作,如果它是空白则无法反序列化(如示例所示).

编辑:反序列化的代码:

XmlSerializer xmlserializer = new XmlSerializer(type);
StringReader strreader = new StringReader(stringXML);
Object o = serializer.Deserialize(strreader);
Run Code Online (Sandbox Code Playgroud)

我该如何处理这种情况

.net c# xml xml-deserialization

17
推荐指数
3
解决办法
2万
查看次数

ASP.Net核心MVC中的本地化无法正常工作 - 无法找到资源文件

在尝试本地化我的应用程序时,我遵循了以下步骤:https: //docs.asp.net/en/latest/fundamentals/localization.html

这是我的代码:

Startup.cs

public List<IRequestCultureProvider> RequestCultureProviders { get; private set; }

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
    services.AddLocalization(options => options.ResourcesPath = "Resources");

    services.AddMvc()
        .AddViewLocalization(options => options.ResourcesPath = "Resources")
        .AddDataAnnotationsLocalization();

    services.AddOptions();

    services.AddTransient<IViewRenderingService, ViewRenderingService>();

    services.AddTransient<IEmailSender, EmailSender>();
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    var locOptions = app.ApplicationServices.GetService<IOptions<RequestLocalizationOptions>>();
    app.UseRequestLocalization(locOptions.Value);

    app.UseStaticFiles();
    app.UseFileServer(new FileServerOptions()
    {
        FileProvider = new PhysicalFileProvider(
        Path.Combine(Directory.GetCurrentDirectory())),
        EnableDirectoryBrowsing = true …
Run Code Online (Sandbox Code Playgroud)

c# globalization asp.net-core-mvc asp.net-core

14
推荐指数
5
解决办法
7510
查看次数

SOAP,JSON和POX在相同的restful wcf中

我想在同一个WCF服务中使用SOAP和RESTful.除了一个问题之外,我已经将它除了.以下是我的web.config:

<service behaviorConfiguration="webBehaviour" name="MyServices">
        <clear />
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttp"
         name="basicHttpBinding" contract="DJSharedServices.IMyServices" />
        <endpoint address="ws" binding="wsHttpBinding" bindingConfiguration="WsHttp"
          name="wsHttpBinding" contract="DJSharedServices.IMyServices" />
        <endpoint address="web" binding="webHttpBinding" bindingConfiguration="WebHttp" behaviorConfiguration="webBehavior"
          name="webHttpBinding" contract="DJSharedServices.IMyServices" />
        <endpoint address="json" binding="webHttpBinding" bindingConfiguration="WebHttp" behaviorConfiguration="webJSONBehavior"
          name="webJSONHttpBinding" contract="DJSharedServices.ISharedServices" />
        <endpoint address="mex" binding="mexHttpBinding"    contract="IMetadataExchange"   name="mexBinding" />        
       </service>    
    </services>
Run Code Online (Sandbox Code Playgroud)

当我有所有端点时,它会给出以下错误:

An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.NullReferenceException: Object reference not set to an instance of an object.
   at System.ServiceModel.Description.WsdlExporter.CreateWsdlBindingAndPort(ServiceEndpoint endpoint, XmlQualifiedName wsdlServiceQName, Port& wsdlPort, Boolean& newBinding, Boolean& bindingNameWasUniquified)
   at System.ServiceModel.Description.WsdlExporter.ExportEndpoint(ServiceEndpoint endpoint, XmlQualifiedName …
Run Code Online (Sandbox Code Playgroud)

rest wcf json soap

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

使用特殊字符快速反序列化XML的方法

我正在寻找快速反序列化xml的方法,它有像ö那样的特殊字符.

我使用的是XMLReader,但无法对这些字符进行反序列化.

有什么建议吗?

编辑:我正在使用C#.代码如下:

XElement element =.. //has the xml
XmlSerializer serializer =   new XmlSerializer(typeof(MyType));
XmlReader reader = element.CreateReader();
Object o= serializer.Deserialize(reader);
Run Code Online (Sandbox Code Playgroud)

c# xml xml-deserialization

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

使用C#以编程方式从outlook中读取邮件

我正在尝试创建一个程序,从Microsoft Outlook中读取我的邮件,以便我可以根据其内容将它们移动到不同的文件夹中.我正在使用Microsoft.Office.Interop.Outlook 12.0,它可以与Outlook 2007一起使用.

如何处理其他用户使用Outlook 2010的情况?

c# outlook

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

将数据从WCF服务公开为oData

是否可以将oData与WCF服务应用程序一起使用但不能使用WCF数据服务?

如果有人能够更多地了解oData,那将会很棒.我已经在这个主题上做了一些谷歌搜索,但每当我搜索"wcf odata"时,我都会获得有关WCF数据服务的信息.

任何帮助/链接将不胜感激.

wcf wcf-data-services odata

5
推荐指数
2
解决办法
5384
查看次数

计算服务器正常运行时间会显示"找不到网络路径"

对于以下代码,我得到了

System.ComponentModel.Win32Exception:找不到网络路径

有人可以帮忙吗?

PerformanceCounter pc = new PerformanceCounter("System",
        "System Up Time");
                pc.MachineName = "1.2.3.4";

                //Normally starts with zero. do Next Value always.
                pc.NextValue();
                TimeSpan ts = TimeSpan.FromSeconds(pc.NextValue());

                Response.Write("This system 1.2.3.4 has been up for " + ts.Days + " days " + ts.Hours + " hours, " + ts.Minutes + " and " + ts.Seconds +" seconds.");
Run Code Online (Sandbox Code Playgroud)

编辑:我尝试了机器名称,我仍然得到相同的错误!注意:1.2.3.4是一个样本值.

c# system.diagnostics health-monitoring

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

在构建之后复制不同位置的文件

要在发布构建后复制不同位置的文件,我尝试了以下操作:

编辑csproj文件并添加此代码,将dll复制到相对路径的bin.

<PropertyGroup>  
<CopyAllFilesToSingleFolderForPackageDependsOn>  
    CustomCollectFiles; 
    $(CopyAllFilesToSingleFolderForPackageDependsOn);  
    </CopyAllFilesToSingleFolderForPackageDependsOn>  
</PropertyGroup> 
<Target Name="CustomCollectFiles">
  <ItemGroup>
    <_CustomFiles Include="..\*project*\**\*.dll" />
    <FilesForPackagingFromProject  Include="%(_CustomFiles.Identity)">
      <DestinationRelativePath>bin\%(Filename)%(Extension)</DestinationRelativePath>
    </FilesForPackagingFromProject>
  </ItemGroup>
</Target>
Run Code Online (Sandbox Code Playgroud)

这绝对没问题.我只是想知道是否可以使用像这样的post build事件来完成..(这不起作用).

if $(ConfigurationName) == Release xcopy /y "$(ProjectDir)$(OutDir)$(TargetFileName)" "$(SolutionDir)$(OutDir)" 
Run Code Online (Sandbox Code Playgroud)

第一种方式是在VS2010中单击发布的"唯一方法"吗?值得关注的是,在VS2010中,csproj文件中的更改不会显示在任何地方.

msbuild copy visual-studio-2010

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

数组到字符串角度

新角度.如果这是一个非常简单的问题,请原谅.

无论如何将数组转换为字符串.我的控制器她的代码:

$scope.addRow = function addRow(){     
    $scope.filters.push({ 'Name':$scope.name, 'dept': $scope.dept, 'city':$scope.city});
    $scope.name='';
    $scope.dept='';
    $scope.city='';
};
Run Code Online (Sandbox Code Playgroud)

现在,我想将此数据作为字符串发送到服务

我希望它的格式为"name,dept,city; name,dept,city".有什么办法吗?

服务代码如下所示:

                $scope.submit = function() {
                   myService.submit({
                      filters :$scope.filters
                 }, function(response) {
                    $scope.response = response; 
                });     
            };
Run Code Online (Sandbox Code Playgroud)

我想将值传递给数组中"name,dept,city; name,dept,city"格式的过滤器.提前致谢.

angularjs

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

在Aurelia中激活后设置页面标题

我正在尝试设置标题,但是在下面的代码中它可以在一个地方工作而在其他地方不起作用.我想获得产品名称并设置标题.还有其他办法吗?

activate(params: any, route, navigationInstruction) {       
        //route.navModel.router.title="test"; //works here
         this.api.pull<Product>([params.id]).then(items => {
                items.forEach(item=>
                {
                    if(item.id == params.id)
                        route.navModel.router.title = item.name //does NOT work here
                });

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

router config page-title aurelia

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