【发布时间】:2017-07-27 12:00:23
【问题描述】:
如果您的 cwd 在您的项目根目录中,OwinHost 非常棒,即
c:/code/myprojectroot> ../location/of/owinhost.exe
当您从项目根目录工作时,只要您的项目中某处有 [assembly: OwinStartup(typeof(MyOwinStartupClass))],OwinHost 似乎非常乐意自动神奇地找到您的类。
但是,如果您尝试将其作为构建脚本的一部分或 cwd 不是项目根目录的其他内容来执行,那么 OwinHost 对您来说就不那么好了,命令行参数意味着您可以告诉它您的项目所在的位置:
c:/not/project/root> location/of/owinhost.exe -d "path/to/project/root"
但是这样做,它总是会告诉你一些讨厌的谎言,比如:
Starting with the default port: 5000 (http://localhost:5000/)
Error: System.EntryPointNotFoundException
The following errors occurred while attempting to load the app.
- No assembly found containing an OwinStartupAttribute.
所以我尝试了以下方法:
c:/not/project/root> location/of/owinhost.exe -d "path/to/project/root" MyOwinStartupClassc:/not/project/root> location/of/owinhost.exe -d "path/to/project/root" MyNamespace.MyOwinStartupClassc:/not/project/root> location/of/owinhost.exe -d "path/to/project/root" MyNamespace.MyOwinStartupClass,MyAssemblyNamec:/not/project/root> location/of/owinhost.exe -d "path/to/project/root/bin/Debug" MyOwinStartupClassc:/not/project/root> location/of/owinhost.exe -d "path/to/project/root/bin/Debug" Namespace.MyOwinStartupClassc:/not/project/root> location/of/owinhost.exe "path/to/project/root"c:/not/project/root> location/of/owinhost.exe "path/to/project/root/bin/Debug/my-assembly-with-owin-startup-in.dll"
没有任何作用,就像 OwinHost 工作的唯一方式是,如果您以 CWD 作为项目根目录运行它,那么任何人都可以阐明我哪里出错了吗?正如我给它的目录 (-d specifies the target directory of the application) 一样,我已经尝试手动给它 DLL,给它上面的任何排列。
所以我想不出任何 Owin-Whisperers 可以告诉我正确的咒语来让它做我想做的事?
【问题讨论】:
-
你试过
c:/not/project/root> location/of/owinhost.exe -d "path/to/project/root/bin/Debug"(即不指定启动类)吗? -
是的,我也试过了,我已经尝试了上面的所有合理排列,有和没有启动类名等。
标签: c# asp.net .net asp.net-web-api2 owin