【问题标题】:Using project katana what is the correct way to specify the startup class in web.config?使用项目武士刀在 web.config 中指定启动类的正确方法是什么?
【发布时间】:2014-08-22 12:50:59
【问题描述】:

在 Katana 中指定 Startup 类的方法之一是通过 web.config 中 appSettings 中的 owin:AppStartup 键

如果 web.config 文件包含一个 appSetting key=“owin:AppStartup”,加载器使用设置值。价值 必须是有效的 .NET 类型名称。
http://msdn.microsoft.com/en-us/magazine/dn451439.aspx

这是我的 web.config 的 app.settings:

<configuration>
  <appSettings>
    <add key="owin:AppStartup" value="MyStartup, MyAssemblyName"/>
  </appSettings>

不幸的是,我收到了这个错误:
尝试加载应用时出现以下错误。
- 对于应用程序启动参数值“MyStartup,MyAssemblyName”,在程序集“MyAssemblyName,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null”中找不到类“MyStartup”。

(我尝试使用完全限定名称 MyAssemblyName,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null,但我得到了同样的错误)

如果我使用在 AssemblyInfo.cs 文件中指定应用启动类的替代方法:

using MyAssemblyName;
...
[assembly:OwinStartup(typeof(MyStartup))]

没有问题。

我做错了什么?

【问题讨论】:

    标签: c# asp.net .net katana


    【解决方案1】:

    我猜你缺少一个命名空间:

    <configuration>
      <appSettings>
        <add key="owin:AppStartup" value="MyAssemblyName.MyStartup, MyAssemblyName"/>
      </appSettings>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-27
      • 1970-01-01
      • 2012-01-25
      • 1970-01-01
      • 2020-06-18
      • 1970-01-01
      相关资源
      最近更新 更多