c# - 类型未标记为可序列化
问题描述
我在.net 4.6.1 web api项目中使用这个命令postbuild。
$(NSwagExe) aspnetcore2swagger "/assembly:$(TargetPath)" "/output:$(OutputPath)swagger.json"
然而它在两个地方失败了,第一个是,
1>System.IO.FileNotFoundException:未找到配置文件“appsettings.json”且不是可选的。物理路径是 'C:\Users\XXXX\source\Workspaces\Information Systems\SOLUTION\SOLUTION.Api\bin\x64\Debug\
appsettings.json 文件与 Startup.cs 位于同一目录中。这就是我得到它的方式
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json")
现在继续前进,只是为了让它工作,如果我硬编码路径它工作但我得到这个错误,
5>System.Runtime.Serialization.SerializationException:在程序集“StructureMap,Version=4.5.0.0,Culture=neutral,PublicKeyToken=null”中键入“StructureMap.StructureMapConfigurationException”未标记为可序列化。
这是我在启动时使用此结构图的地方之一,
Start.LogicContainer.Configure(x => x.For<DBContext>().Use<DBContext>()
.Ctor<string>("nameOrConnectionString").Is(Configuration.GetConnectionString("DefaultConnection")));
我想要的只是在每次构建时生成 swagger.json 文件。
解决方案
推荐阅读
- react-native - React Native Modal transparent with backgroundColor black opacity 0.5 在场景之间变得更暗
- c++ - 为什么 scons 在 SConscript 中忽略我的 CXXFlags
- php - 在 Woocommerce 的产品变体描述中允许使用简码
- selenium - 如何让 capybara chrome 无头打开 sweetalert2 模态以进行 Rspec 测试
- python - TypeError:'str' 对象不可调用 Python 3.7.0
- angular - Angular 6 Forms找不到控制错误
- vue.js - Vue如何在组件中使用id?
- ios - 重新加载 UITableView 中的部分数
- amazon-web-services - Amazon S3 存储桶策略为存储桶中的特定文件夹设置“内容类型”为“应用程序/pdf”
- python - 在整个 Pandas DataFrame 中获取具有最小值的行和列