从我的.csproj文件:
<Content Include="log4net.config">
<SubType>Designer</SubType>
</Content>
<Content Include="log4net.Release.config">
<DependentUpon>log4net.config</DependentUpon>
</Content>
<Content Include="log4net.Debug.config">
<DependentUpon>log4net.config</DependentUpon>
</Content>
<Content Include="log4net.Live.config">
<DependentUpon>log4net.config</DependentUpon>
</Content>
<Content Include="log4net.Demo.config">
<DependentUpon>log4net.config</DependentUpon>
</Content>
Run Code Online (Sandbox Code Playgroud)
在我的.csproj文件的底部:
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<Target Name="AfterCompile" Condition="exists('log4net.$(Configuration).config')">
<TransformXml Source="log4net.config"
Destination="$(IntermediateOutputPath)$(TargetFileName).config"
Transform="log4net.$(Configuration).config" />
<ItemGroup>
<AppConfigWithTargetPath Remove="log4net.config"/>
<AppConfigWithTargetPath Include="$(IntermediateOutputPath)$(TargetFileName).config">
<TargetPath>$(TargetFileName).config</TargetPath>
</AppConfigWithTargetPath>
</ItemGroup>
</Target>
Run Code Online (Sandbox Code Playgroud)
来自log4net.config
<connectionString name="ConnName"
value="Data Source=localhost\sqlexpress;Initial Catalog=localdb;Persist Security Info=True;Integrated Security=SSPI;" />
Run Code Online (Sandbox Code Playgroud)
从log4net.Live.config(删除敏感数据)
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionString name="ConnName" value="Data Source=127.0.0.1;Initial Catalog=DBName;Persist Security Info=True;User ID=userid;Password=pword"
providerName="System.Data.SqlClient" xdt:Transform="Replace" xdt:Locator="Match(name)" />
</configuration>
Run Code Online (Sandbox Code Playgroud)
我检查了msbuild输出,我看到它正确地转换了我的web.config,但我看到没有输出它转换log4net.此外,当我在发布后检查log4net.config文件时,它具有原始连接字符串.
我究竟做错了什么 :)?
谢谢!
更新 …
asp.net msbuild configuration visual-studio-2010 slowcheetah
TrackableCollection(context.Entities.Add(entity))(EntityState = New)TrackableCollection(context.Entities.Remove(entity))中删除添加的实体(EntityState = Unmodified)context.SubmitChanges())我仍然从与实体关联的数据注释中获得验证错误,为什么?
public class Entity
{
[Required]
public string Name { get; set; }
}
Run Code Online (Sandbox Code Playgroud) c# entity-framework entity-framework-4 self-tracking-entities
在Visual Studio中,有一个命令可以删除未使用的using语句
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
Run Code Online (Sandbox Code Playgroud)
使用未使用的产品是否会受到性能影响?
例如:
DataTable table = new DataTable()
{
Columns = new DataColumnCollection(
{
new DataColumn("col1"),
new DataColumn("col2")
})
});
Run Code Online (Sandbox Code Playgroud) 启动了一个新的ASP.NET MVC 3应用程序并收到以下错误:
无法删除主键值,因为仍然存在对此键的引用.
怎么解决这个?
型号(EF代码优先)
public class Journal
{
public int JournalId { get; set; }
public string Name { get; set; }
public virtual List<JournalEntry> JournalEntries { get; set; }
}
public class JournalEntry
{
public int JournalEntryId { get; set; }
public int JournalId { get; set; }
public string Text { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
调节器
//
// POST: /Journal/Delete/5
[HttpPost, ActionName("Delete")]
public ActionResult DeleteConfirmed(int id)
{
Journal journal = db.Journals.Find(id);
db.Journals.Remove(journal);
db.SaveChanges(); // **exception occurs …Run Code Online (Sandbox Code Playgroud) c# asp.net asp.net-mvc entity-framework entity-framework-4.1
我正进入(状态:
类型'ASP._Page_index_cshtml'不从'System.Web.WebPages.WebPage'继承.
当我浏览到我的index.cshtml文件.这很简单:
@using System.Web.Optimization
@inherits System.Web.Mvc.WebViewPage
<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width">
<title>Hello World</title>
@Styles.Render("~/Content/css", "~/Content/themes/base/css")
@Scripts.Render("~/bundles/modernizr")
</head>
<body>
@Scripts.Render(
"~/bundles/jquery",
"~/bundles/jqueryui"
)
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我的index.cshtml文件在Views文件夹之外,如果这很重要的话.
通过TEST菜单或右键单击上下文菜单调试单元测试时,VS2013在将代码更改为当前c#测试类后始终忽略单元测试中的断点.第二次调试会导致断点被击中.
更新
上传的示例项目:https://github.com/subt13/BugSamples
我已经重现了在使用MVVMLight框架的Windows 10 UAP应用程序中发生的错误.
在CPU处于高负载(~20-25%)且页面"重"(大图像,大量控件等等)时,我在导航期间收到以下错误
at System.Runtime.InteropServices.WindowsRuntime.ICommandAdapterHelpers.<> c__DisplayClass2.b__3(Object sender,EventArgs e),位于RaiseExecuteChangeRepo的GalaSoft.MvvmLight.Command.RelayCommand.RaiseCanExecuteChanged()的System.EventHandler.Invoke(Object sender,EventArgs e) .ViewModel.MainViewModel.d__17.MoveNext()
在示例中,发生错误 RaiseCanExecuteChanged();
private async void ExecuteLoadDataCommandAsync()
{
// cause the app to slow done.
var data = await Task.Run(() => GetData());
if (data != null)
{
this.Data.Clear();
foreach (var item in data)
{
this.Data.Add(new AnotherVM(item));
}
}
// have the select job command rerun its condition
this.SelectCommand.RaiseCanExecuteChanged();
}
// slow down the page
public List<DataItem> GetData()
{
var myList = new List<DataItem>();
for …Run Code Online (Sandbox Code Playgroud) 我需要阅读AssemblyFileVersiondll而不仅仅是Version.我试过了:
<Target Name="RetrieveIdentities">
<GetAssemblyIdentity AssemblyFiles="some.dll">
<Output
TaskParameter="Assemblies"
ItemName="MyAssemblyIdentities"/>
</GetAssemblyIdentity>
<Message Text="%(MyAssemblyIdentities.FileVersion)" />
</Target>
Run Code Online (Sandbox Code Playgroud)
该脚本运行但不输出任何内容.如果我改变FileVersion到Version它正确输出AssemblyVersion.我如何AssemblyFileVersion使用我的脚本?
我刚开始使用这么多数据(2000万行)而且我不知道在查询持续时间方面我应该期待什么:
update table set field = '1234'
Run Code Online (Sandbox Code Playgroud)
现场没有索引.这个声明花了25分钟.数据库设置为"简单恢复".25分钟似乎太长了吗?表有9列,小数据类型<50 varchar.
c# ×5
asp.net ×4
asp.net-mvc ×2
msbuild ×2
.net-4.0 ×1
async-await ×1
mvvm-light ×1
performance ×1
razor ×1
slowcheetah ×1
sql ×1
sql-server ×1
versioning ×1