我的电脑上的visual studio 2012在"公共网站"中预览时收到以下错误消息.我需要重新启动VS以消除错误消息.
由于异常'指定条件'$(PackageAsSingleFile)"评估为"而不是布尔值,因此调用构建失败.C:\ Program Files(x86)\ MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets'
是什么原因造成的?
我创建了一个Web项目,它在Visual Studio中运行良好.但是,在将其发布到azurewebsites后,我收到以下错误.什么可能导致这个问题?
无法加载文件或程序集'System.Web.Http.WebHost,Version = 5.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(HRESULT异常:0x80131040)
描述:执行当前Web请求期间发生未处理的异常.请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息.
异常详细信息:System.IO.FileLoadException:无法加载文件或程序集'System.Web.Http.WebHost,Version = 5.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(HRESULT异常:0x80131040)
来源错误:
在执行当前Web请求期间生成了未处理的异常.可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息.
程序集加载跟踪:以下信息有助于确定无法加载程序集"System.Web.Http.WebHost,Version = 5.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35"的原因.
警告:装配绑定日志记录已关闭.要启用程序集绑定失败日志记录,请将注册表值[HKLM\Software\Microsoft\Fusion!EnableLog](DWORD)设置为1.注意:程序集绑定失败日志记录会导致一些性能损失.要关闭此功能,请删除注册表值[HKLM\Software\Microsoft\Fusion!EnableLog].
以下是web.config文件的一部分.
  <system.web>
    <customErrors mode="Off"/>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="2880" />
    </authentication>
    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
      </namespaces>
    </pages>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
  <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove …Run Code Online (Sandbox Code Playgroud) @pytest.fixture
def d_service():
    c = DService()
    return c
# @pytest.mark.asyncio  # tried it too
async def test_get_file_list(d_service):
    files = await d_service.get_file_list('')
    print(files)
Run Code Online (Sandbox Code Playgroud)
然而,却出现了以下错误?
已收集 0 项 / 1 错误
===================================== 错误============== =====================
________________ 收集测试/e2e_tests/test_d.py 时出错 _________________
..\..\..\..\..\anaconda3\lib\site-packages\pluggy\__init__.py:617: 在 __call__ 中
    返回 self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
..\..\..\..\..\anaconda3\lib\site-packages\pluggy\__init__.py:222: 在 _hookexec 中
    返回 self._inner_hookexec(钩子、方法、kwargs)
..\..\..\..\..\anaconda3\lib\site-packages\pluggy\__init__.py:216:在
    第一个结果=hook.spec_opts.get('第一个结果'),
..\..\..\..\..\anaconda3\lib\site-packages\_pytest\python.py:171:在 pytest_pycollect_makeitem 中
    res = 结果.get_result()
..\..\..\..\..\anaconda3\lib\site-packages\anyio\pytest_plugin.py:98:在 pytest_pycollect_makeitem 中
    标记=collector.get_closest_marker('anyio')
E AttributeError:“模块”对象没有属性“get_closest_marker”
!!!!!!!!!!!!!!!!!!!!! 已中断:收集期间出现 1 个错误!!!!!!!!!!!!!!!!!!
=========================== 2.53 秒内出现 1 个错误 ================== =========
我安装了以下软件包。错误消失,但测试被跳过。
pip install …Run Code Online (Sandbox Code Playgroud) 在以下控制台应用程序(.Net core 2.0)中,scaffold-dbcontext创建了以下内容DbContext
public partial class MyContext : DbContext
{
    public virtual DbSet<Tables> Tables { get; set; }
    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        if (!optionsBuilder.IsConfigured) { optionsBuilder.UseSqlServer(Program.Conn); }
    }
    protected override void OnModelCreating(ModelBuilder modelBuilder) { .... }
}
Run Code Online (Sandbox Code Playgroud)
在Main()(static void Main(string[] args))中,代码如下
var services = new ServiceCollection();
var conn = configuration.GetConnectionString("MySource");
services.AddDbContext<MyContext>(o => o.UseSqlServer(conn)); // Error
Run Code Online (Sandbox Code Playgroud)
得到以下运行时错误?
使用配置调用AddDbContext,但上下文类型"MyContext"仅声明无参数构造函数.这意味着永远不会使用传递给AddDbContext的配置
我正在创建一个Asp.Net MVC 5网站.我需要在ApplicationUser中添加自定义字段并将其与其他模型关联(添加外键).我想我应该只使用一种上下文类型.但是,代码脚手架已生成以下ApplicationDbContext类.我可以把我所有public DbSet<...> ... { get; set; }的课都放进去吗?还是有更好的模式?
namespace MyApp.Models
{
    // You can add profile data for the user by adding more properties to your User class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more.
    public class ApplicationUser : User
    {  
    }
    public class ApplicationDbContext : IdentityDbContextWithCustomUser<ApplicationUser>
    {
    }
}
Run Code Online (Sandbox Code Playgroud) 我正在使用VS2013创建一个Asp.Net MVC项目,并使用nuget添加了hottowel(2.0.1).但是,微风不适用于Entity Framework 6.
如何将创建项目的Entity Framework 6降级为EF5?
我在下面添加了以下部分project.json.
  "commands": {
    "run": "run server.urls=http://localhost:8082",
    "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:8082",
    "weblistener": "Microsoft.AspNet.Hosting --server WebListener --server.urls http://localhost:8082"
  },
Run Code Online (Sandbox Code Playgroud)
但是,它仍然显示"正在侦听:http:// localhost:5000 "运行时使用dotnet myapp.dll?
顺便说一下,来自其他机器的客户能否访问该服务?
为什么属性在编译方法时会出错?
public interface IFoo {}
public interface IBar<out T> where T : IFoo {}
public interface IItem<out T> where T: IFoo
{
    // IEnumerable<IBar<T>> GetList(); // works
    IEnumerable<IBar<T>> ItemList { get; set; } // Error!
}
Run Code Online (Sandbox Code Playgroud)
错误:
方差无效:类型参数"T"必须在"UserQuery.IItem <T> .ItemList"上具有矛盾的有效性.'T'是协变的.
(1 row(s) affected)每次执行时,SSMS都会显示额外的内容insert/update.例如,执行以下SQL
declare @a table (a int)
insert into @a values (1), (2)
update @a set a = 3 
Run Code Online (Sandbox Code Playgroud)
SSMS将显示以下消息.
(2 row(s) affected) (1 row(s) affected) (2 row(s) affected) (1 row(s) affected)
我没有找到任何数据库/服务器触发器.什么可能导致额外的(1 row(s) affected)?
以下代码得到了错误.为.Net Core 2.0控制台应用程序设置日志记录和配置管理的正确方法是什么?
错误CS1061'LoggerFactory'不包含'AddConsole'的定义,并且没有可以找到接受类型'LoggerFactory'的第一个参数的扩展方法'AddConsole'(您是否缺少using指令或程序集引用?)
错误CS1503参数2:无法从"Microsoft.Extensions.Configuration.IConfigurationSection"转换为"System.Action"
class Program
{
    static void Main(string[] args)
    {
        var services = new ServiceCollection();
        ConfigureServices(services);
        var serviceProvider = services.BuildServiceProvider();
        var app = serviceProvider.GetService<Application>();
        Task.Run(() => app.Run()).Wait();
    }
    private static void ConfigureServices(IServiceCollection services)
    {
        ILoggerFactory loggerFactory = new LoggerFactory()
            .AddConsole() // Error!
            .AddDebug();
        services.AddSingleton(loggerFactory); // Add first my already configured instance
        services.AddLogging(); // Allow ILogger<T>
        IConfigurationRoot configuration = GetConfiguration();
        services.AddSingleton<IConfigurationRoot>(configuration);
        // Support typed Options
        services.AddOptions();
        services.Configure<MyOptions>(configuration.GetSection("MyOptions")); // Error!
        services.AddTransient<Application>();
    }
    private static IConfigurationRoot GetConfiguration()
    {
        return new …Run Code Online (Sandbox Code Playgroud) c# ×4
.net-core ×3
.net ×2
asp.net ×2
asp.net-mvc ×2
asp.net-core ×1
azure ×1
covariance ×1
msbuild ×1
pytest ×1
python ×1
sql-server ×1