• <bdo id='LEY8p'></bdo><ul id='LEY8p'></ul>
    <i id='LEY8p'><tr id='LEY8p'><dt id='LEY8p'><q id='LEY8p'><span id='LEY8p'><b id='LEY8p'><form id='LEY8p'><ins id='LEY8p'></ins><ul id='LEY8p'></ul><sub id='LEY8p'></sub></form><legend id='LEY8p'></legend><bdo id='LEY8p'><pre id='LEY8p'><center id='LEY8p'></center></pre></bdo></b><th id='LEY8p'></th></span></q></dt></tr></i><div id='LEY8p'><tfoot id='LEY8p'></tfoot><dl id='LEY8p'><fieldset id='LEY8p'></fieldset></dl></div>
  1. <small id='LEY8p'></small><noframes id='LEY8p'>

    1. <tfoot id='LEY8p'></tfoot>

    2. <legend id='LEY8p'><style id='LEY8p'><dir id='LEY8p'><q id='LEY8p'></q></dir></style></legend>

    3. T4 模板无法加载文件或程序集“System.Runtime,版本 = 4.2.0.0"

      T4 Template Could not load file or assembly #39;System.Runtime, Version = 4.2.0.0#39;(T4 模板无法加载文件或程序集“System.Runtime,版本 = 4.2.0.0)

          <tbody id='2Xbrr'></tbody>
        • <i id='2Xbrr'><tr id='2Xbrr'><dt id='2Xbrr'><q id='2Xbrr'><span id='2Xbrr'><b id='2Xbrr'><form id='2Xbrr'><ins id='2Xbrr'></ins><ul id='2Xbrr'></ul><sub id='2Xbrr'></sub></form><legend id='2Xbrr'></legend><bdo id='2Xbrr'><pre id='2Xbrr'><center id='2Xbrr'></center></pre></bdo></b><th id='2Xbrr'></th></span></q></dt></tr></i><div id='2Xbrr'><tfoot id='2Xbrr'></tfoot><dl id='2Xbrr'><fieldset id='2Xbrr'></fieldset></dl></div>

              <tfoot id='2Xbrr'></tfoot>

            • <legend id='2Xbrr'><style id='2Xbrr'><dir id='2Xbrr'><q id='2Xbrr'></q></dir></style></legend>
                <bdo id='2Xbrr'></bdo><ul id='2Xbrr'></ul>

                <small id='2Xbrr'></small><noframes id='2Xbrr'>

              • 本文介绍了T4 模板无法加载文件或程序集“System.Runtime,版本 = 4.2.0.0"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                所以我有一个 T4 模板,我试图在设计时运行,但它一直给我以下错误.

                So I have a T4 Template I'm trying to run at design-time, but it keeps giving me the following error.

                Running transformation: System.IO.FileNotFoundException: Could not load 
                file or assembly 'System.Runtime, Version=4.2.0.0, Culture=neutral, 
                PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system 
                cannot find the file specified.
                File name: 'System.Runtime, Version=4.2.0.0, Culture=neutral, 
                PublicKeyToken=b03f5f7f11d50a3a'
                

                我的 Visual Studios 解决方案包含 10 个项目,所有项目都针对 .Net Core 2.0 框架.我的 T4 模板目前如下所示:

                My Visual Studios solution has 10 projects contained within it, all of which target .Net Core 2.0 framework. My T4 template presently looks as such:

                <#@ template debug="false" hostspecific="false" language="C#" #>
                <#@ assembly name="System.Core" #>
                <#@ import namespace="System.Linq" #>
                <#@ import namespace="System.Text" #>
                <#@ import namespace="System.Reflection" #>
                <#@ import namespace="Services.Resources.DataTransferObjects.Infrastructures" #>
                <#@ import namespace="System.Collections.Generic" #> 
                <#@ assembly name="$(TargetDir)Services.dll" #>
                
                
                <#@ output extension=".cs" #>
                public class AdminDTO
                {
                        <#var editableObjs = Assembly
                            .GetAssembly(typeof(GenericEditable<>))
                            .GetTypes()
                            .Where(p => p.BaseType != null && p.BaseType.IsGenericType && p.BaseType.GetGenericTypeDefinition() == (typeof(GenericEditable<>)))
                            .ToList();
                        #>
                }
                

                目前我只需要我在模板中引用的程序集,这是一个 .Net Core 2.0 类库项目.我已经尝试在这个特定的库中添加 System.Runtime.dll 引用,但它似乎没有任何区别.

                At the moment I only need the assembly I've referenced in the template, which is a .Net Core 2.0 class library project. I've tried adding the System.Runtime.dll reference in this particular library, but it doesn't appear to make any difference.

                我已经阅读了与此类似的其他几个问题,一般看来 .Net Core 似乎与 T4 模板存在问题,但似乎大多数人的解决方案都是针对 .Net 标准库.我不确定这是否适用于我,因为我的整个解决方案只涉及 .Net Core 项目.

                I've read several other issues similar to this, and it generally seems that .Net Core seems to have issues with T4 Templates, but it appeared most peoples' solutions were to target a .Net Standard library. I'm not sure this is applicable for me, as my entire solution only involves .Net Core projects.

                编辑

                我将我的所有项目都改为 .Net Standard 2.0 而不是 .Net Core,这解决了我最初的问题,但现在我看到了这个错误:

                I changed all my projects to target .Net Standard 2.0 instead of .Net Core, and that fixed my initial problem, but now I see this error:

                System.Reflection.ReflectionTypeLoadException: Unable to load one or 
                more of the requested types. Retrieve the LoaderExceptions property for 
                more information.
                at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
                at System.Reflection.RuntimeModule.GetTypes()
                at System.Reflection.Assembly.GetTypes()
                

                推荐答案

                我找到了 System.Runtime dll 错误的解决方法.

                I found a workaround for the System.Runtime dll error.

                将此 bindingRedirect 放入 C:UsersAppDataLocalMicrosoftVisualStudio15.0_29f8d23adevenv.exe.config -> <runtime> -> <assemblyBinding> 其他的 bindingRedirect 在哪里

                Put this bindingRedirect inside the C:Users<user>AppDataLocalMicrosoftVisualStudio15.0_29f8d23adevenv.exe.config inside <configuration> -> <runtime> -> <assemblyBinding> where are all the others bindingRedirect's

                <dependentAssembly>
                  <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
                  <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="4.0.0.0"/>
                </dependentAssembly>
                

                这是 Visual Studio 或 T4 模板引擎中的错误:https://developercommunity.visualstudio.com/content/problem/358905/filenotfoundexception-systemruntime-version4210-wh.html

                It's a bug in Visual Studio or T4 Template Engine: https://developercommunity.visualstudio.com/content/problem/358905/filenotfoundexception-systemruntime-version4210-wh.html

                这篇关于T4 模板无法加载文件或程序集“System.Runtime,版本 = 4.2.0.0"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Force JsonConvert.SerializeXmlNode to serialize node value as an Integer or a Boolean(强制 JsonConvert.SerializeXmlNode 将节点值序列化为整数或布尔值)
                Using JSON to Serialize/Deserialize TimeSpan(使用 JSON 序列化/反序列化 TimeSpan)
                Could not determine JSON object type for type quot;Classquot;(无法确定类型“Class的 JSON 对象类型.)
                How to deserialize a JSONP response (preferably with JsonTextReader and not a string)?(如何反序列化 JSONP 响应(最好使用 JsonTextReader 而不是字符串)?)
                how to de-serialize JSON data in which Timestamp it-self contains fields?(如何反序列化时间戳本身包含字段的JSON数据?)
                JSON.Net custom contract serialization and Collections(JSON.Net 自定义合约序列化和集合)
              • <small id='oITy3'></small><noframes id='oITy3'>

                  <tfoot id='oITy3'></tfoot>
                  <i id='oITy3'><tr id='oITy3'><dt id='oITy3'><q id='oITy3'><span id='oITy3'><b id='oITy3'><form id='oITy3'><ins id='oITy3'></ins><ul id='oITy3'></ul><sub id='oITy3'></sub></form><legend id='oITy3'></legend><bdo id='oITy3'><pre id='oITy3'><center id='oITy3'></center></pre></bdo></b><th id='oITy3'></th></span></q></dt></tr></i><div id='oITy3'><tfoot id='oITy3'></tfoot><dl id='oITy3'><fieldset id='oITy3'></fieldset></dl></div>

                        <tbody id='oITy3'></tbody>
                      <legend id='oITy3'><style id='oITy3'><dir id='oITy3'><q id='oITy3'></q></dir></style></legend>
                        • <bdo id='oITy3'></bdo><ul id='oITy3'></ul>