2016-07-14 13 views
1

私は.netコアアプリケーションの初心者です。私は "net461"(フルフレームワーク)を対象としたasp.netコア(1.0 - > MVC6)を開発しています。私の問題は、私はクラスライブラリフレームワークを参照する4.6.1からasp.netコア.netフルフレームワーク4.6.1

enter image description here

することができます:

{ 
    "dependencies": { 
    "KendoUICore": "2016.2.607", 
    "Microsoft.AspNetCore.Razor.Tools": { 
     "version": "1.0.0-preview1-final", 
     "type": "build" 
    }, 
    "Microsoft.Dnx.Compilation.CSharp.Abstractions": "1.0.0-rc1-final", 
    "Microsoft.Extensions.CompilationAbstractions": "0.0.1-alpha", 
    "System.Linq.Queryable": "4.0.0", 
    "Telerik.DataAccess.Core": "2016.1.224.1", 
    "Microsoft.AspNetCore.Diagnostics": "1.0.0", 
    "Microsoft.AspNetCore.Mvc": "1.0.0", 
    "Microsoft.AspNetCore.Mvc.Formatters.Xml": "1.0.0", 
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", 
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0", 
    "Microsoft.AspNetCore.StaticFiles": "1.0.0", 
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", 
    "Microsoft.Extensions.Configuration.Json": "1.0.0", 
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0", 
    "Microsoft.Extensions.Logging": "1.0.0", 
    "Microsoft.Extensions.Logging.Console": "1.0.0", 
    "Microsoft.Extensions.Logging.Debug": "1.0.0", 
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0", 
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.0", 
    "Microsoft.AspNet.Identity.Owin": "2.2.1", 
    "Microsoft.Owin.Host.SystemWeb": "3.0.1", 
    "Microsoft.AspNetCore.Session": "1.0.0", 
    "jQuery": "3.0.0.1" 
    }, 

    "tools": { 
    "Microsoft.AspNetCore.Razor.Tools": { 
     "version": "1.0.0-preview1-final", 
     "imports": "portable-net45+win8+dnxcore50" 
    }, 
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": { 
     "version": "1.0.0-preview1-final", 
     "imports": "portable-net45+win8+dnxcore50" 
    }, 
    "Microsoft.Extensions.SecretManager.Tools": { 
     "version": "1.0.0-preview1-final", 
     "imports": "portable-net45+win8+dnxcore50" 
    } 
    }, 

    "frameworks": { 
    "net461": { 
     "dependencies": { 
     "OmniPayDataModel": { 
      "target": "project" 
     } 
     } 
    } 
    }, 

    "buildOptions": { 
    "emitEntryPoint": true, 
    "preserveCompilationContext": true 
    }, 

    "publishOptions": { 
    "include": [ 
     "wwwroot", 
     "Views", 
     "appsettings.json", 
     "web.config" 
    ] 
    }, 

    "scripts": { 
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ], 
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] 
    }, 
    "userSecretsId": "aspnet-OmniAdminConcept-Mvc6CoreWin-20160622113707" 
} 

私は(telerik.DataAccess.Coreを使用)OmniPayDataModelと呼ばれるフレームワーク4.6.1を対象にクラスライブラリを追加するために必要な以下はproject.jsonです「がtは私のasp.net MVCプロジェクト投げ、次のエラーからOmniPayDataModel.dllを参照:

enter image description here

しかし、csprojを参照として追加することは可能ですが(project.jsonが示すようにプロジェクトをターゲットにしています)、何らかの理由でOmniPayDataModel.dllをビルド/再構築するときにソリューションを実行するときに変更が反映されません(例:displaynameのようなDataannotationsを私のクラスモデル<label asp-for="..." />は、表示するテキストを表示しません)。スニペットコードを次に示します。

namespace DataModel 
{ 
    [MetadataType(typeof(Directory.DirectoryMetadata))] 
    public partial class Directory 
    { 
     internal sealed class DirectoryMetadata 
     { 
      public DirectoryMetadata() 
      { 
      } 

      [Display(Name = "Id Directorio")] 
      [Required()] 
      public string DirectoryId 
      { get; set; } 

      [Display(Name = "Nombre Completo")] 
      [Required()] 
      public string DirectoryFullName 
      { get; set; } 

申し訳ありませんが、私は間違っているんだけど、なぜ私は私のメインのプロジェクトにDLLの参照を追加することはできませんか?メインプロジェクトがcsprojを参照として追加したのはなぜですか?しかし変更は反映されません。

答えて

1

自分で解決策を見つけました。

Asp.Netコアプロジェクトでは、csproj(クラスライブラリ)を参照するのに不便はなく、そのクラスライブラリに加えられた変更はうまく反映されます。私は、根本的な問題がMetadataType属性の機能をAsp.Netコアプロジェクトに指しているときに、非互換性を参照するようにしたという問題に遭遇しました。

私はMicrosoft.AspNetCore.Mvc.CoreアセンブリからModelMetadataTypeAttribute代わりのMetadataTypeAttributeを使用する必要がありました。メタデータクラス(バディクラス)のデコレーションは、Display(...)、DisplayName(...)の使用方法と同じです。バディークラス(メタデータクラス)がモデルクラスの外部または内部にあるかどうかに関係なく、

ただし、バディクラスではなくモデルクラスで直接MetadataTypeAttributeを使用すると、完全に機能します。

この相違について私が与える可能性のある唯一の説明は、新しく登場するMicrosoft Asp.Netコアテクノロジ、DLLプロセスと機能の再配置に関するものです。