在VS2012上运行单元测试最近非常慢,当我运行它们需要大约12秒才开始实际测试.
当我调试它时,在我遇到第一个断点之前是同一个故事.
我连接了进程监视器然后我发现了这个:
CreateFile \\WORKSTATION*\MAILSLOT\NET\NETLOGON SUCCESS
WriteFile \\WORKSTATION*\MAILSLOT\NET\NETLOGON BAD NETWORK PATH
之后它会保持9秒安静.
CloseFile \\WORKSTATION*\MAILSLOT\NET\NETLOGON SUCCESS
这到底是怎么回事?我根本找不到MAILSLOT和Visual Studio之间的任何关系,但它现在持续了大约2周.
我在我的模式中有这个:
[Required(AllowEmptyStrings = false, ErrorMessageResourceType = typeof(Registration), ErrorMessageResourceName = "NameRequired")]
[MinLength(3, ErrorMessageResourceType = typeof(Registration), ErrorMessageResourceName = "NameTooShort")]
public String Name { get; set; }
Run Code Online (Sandbox Code Playgroud)
最终结果如下:
<div class="editor-label">
<label for="Name">Name</label>
</div>
<div class="editor-field">
<input class="text-box single-line" data-val="true" data-val-required="Name is required" id="Name" name="Name" type="text" value="" />
<span class="field-validation-valid" data-valmsg-for="Name" data-valmsg-replace="true"></span>
</div>
Run Code Online (Sandbox Code Playgroud)
为什么MinLength会被编译器忽略?我怎么能"开启"?
我不是MVVM模式的常规,这基本上是我第一次玩它.
我以前做的("普通"WPF)是用业务层创建我的视图,也许是数据层(通常包含我的服务或实体框架创建的实体).
现在经过一些玩弄我从MVVM Light创建了一个标准模板,并做到了这一点:
定位:
public class ViewModelLocator
{
static ViewModelLocator()
{
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
if (ViewModelBase.IsInDesignModeStatic)
{
SimpleIoc.Default.Register<IUserService, DesignUserService>();
}
else
{
SimpleIoc.Default.Register<IUserService, IUserService>();
}
SimpleIoc.Default.Register<LoginViewModel>();
}
public LoginViewModel Login
{
get
{
return ServiceLocator.Current.GetInstance<LoginViewModel>();
}
}
}
Run Code Online (Sandbox Code Playgroud)
登录ViewModel:
public class LoginViewModel : ViewModelBase
{
private readonly IUserService _userService;
public RelayCommand<Object> LoginCommand
{
get
{
return new RelayCommand<Object>(Login);
}
}
private string _userName;
public String UserName
{
get { return _userName; }
set
{
if (value == _userName)
return; …
Run Code Online (Sandbox Code Playgroud) 如何newsequentialid()
在PK列中使用默认值?
我有这个注释:
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
Run Code Online (Sandbox Code Playgroud)
但是这会产生随机的guid,我希望有顺序的guid.
我可以手动将数据库设置newsequentialid()
为默认值,但是没有更好的选择吗?或者EF团队忘记了这个选项?
我有一个应用程序,它不从本地磁盘读取任何文件或不尝试写任何东西.
它在本地文件系统上运行完美,但它需要在几百个工作站上运行,所以我将它放在Win2003服务器上的共享上.
但是当我尝试在UNC的XP工作站上启动时:
system.io.fileloadexception
这可能是什么问题?
我有2个简单的类:
public class Setting
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public Guid SettingId { get; set; }
[Required]
public String Name { get; set; }
public String Value { get; set; }
[Required]
public SettingCategory SettingCategory { get; set; }
}
public class SettingCategory
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public Guid SettingCategoryId { get; set; }
[Required]
public String Value { get; set; }
public ICollection<Setting> Settings { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
当我SettingCategory
从数据库中检索a时,集合Settings始终为null.
当我做它virtual
然后会说:The ObjectContext instance has been disposed and …
我们在该公司有一个运行5/6开发人员的ASP.NET项目.所有Visual Studio 2017和IIS Express上的调试,没有疯狂的设置或任何使其运行的东西.
1位同事无法让它工作,他总是得到以下例外:
几个月前我们遇到了这个问题,然后出于挫败感重新安装了PC,问题就消失了.他没有发展几周,今天又出现了问题.
我搜索了很长时间,但这是一个普遍的错误,我无法真正解决这个问题.
当我运行融合日志查看器时,我看到以下结果:
The operation failed.
Bind result: hr = 0x80131018. No description available.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Program Files\IIS Express\iisexpress.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = System.ServiceModel.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Users/User/Projects/project/project.UserSite/
LOG: Initial PrivatePath = C:\Users\User\Projects\project\project.UserSite\bin
LOG: Dynamic Base = C:\Users\User\AppData\Local\Temp\Temporary ASP.NET Files\vs\e0254dae
LOG: Cache Base = C:\Users\User\AppData\Local\Temp\Temporary ASP.NET Files\vs\e0254dae
LOG: AppName = 38c6ff11
Calling assembly : …
Run Code Online (Sandbox Code Playgroud) 我通过取消选中publish属性来禁用Visual Studio中的更新检查The application should check for updates
。
我的应用程序检查更新,用户必须选择拒绝更新。
问题是,当用户跳过更新时,下次他启动应用程序时,将再次显示默认的ClickOnce更新屏幕。
如何确保它永远不会显示默认的ClickOnce更新对话框?
我的更新代码:
private void CheckForUpdates()
{
if (!ApplicationDeployment.IsNetworkDeployed)
{
return;
}
var currentDeployment = ApplicationDeployment.CurrentDeployment;
UpdateCheckInfo info;
try
{
info = currentDeployment.CheckForDetailedUpdate();
}
catch (Exception e)
{
return;
}
if (!info.UpdateAvailable)
{
return;
}
var changelogDialog = new Changelog();
if (changelogDialog.ShowDialog() != true)
{
return;
}
currentDeployment.Update();
Exit();
}
Run Code Online (Sandbox Code Playgroud)
这是我的清单:
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns="urn:schemas-microsoft-com:asm.v2" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xrml="urn:mpeg:mpeg21:2003:01-REL-R-NS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:co.v1="urn:schemas-microsoft-com:clickonce.v1" xmlns:co.v2="urn:schemas-microsoft-com:clickonce.v2">
<assemblyIdentity name="test.ccpl.Desktop.application" version="1.0.0.89" …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Android与KSOAP2一起发布到我自己的测试肥皂服务器(C#).
现在我有来自SOAP服务器的规范,它期望:
POST /SharingpointCheckBarcode.asmx HTTP/1.1
Host: awc.test.trin-it.nl
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/checkBarcode"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<AuthHeader xmlns="http://tempuri.org/">
<username>string</username>
<password>string</password>
</AuthHeader>
</soap:Header>
<soap:Body>
<checkBarcode xmlns="http://tempuri.org/">
<barcode>string</barcode>
</checkBarcode>
</soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)
但Android KSOAP2发出的是:
<?xml version="1.0" encoding="utf-8"?>
<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header />
<v:Body>
<checkBarcode xmlns="http://tempuri.org" id="o0" c:root="1">
<username i:type="d:string">test</username>
<password i:type="d:string">test</password>
<barcode i:type="d:string">2620813000301</barcode>
</checkBarcode>
</v:Body>
</v:Envelope>
Run Code Online (Sandbox Code Playgroud)
使用此代码:
try {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("username", "test");
request.addProperty("password", "test");
request.addProperty("barcode", "2620813000301");
SoapSerializationEnvelope envelope = new …
Run Code Online (Sandbox Code Playgroud) 我试图用Ajax将它提交给MVC3控制器:
var params = {
'productId': productId,
'list': []
};
$.each($('.specificationId'), function () {
var specId = $(this).attr('id').replace('specification_', '');
var specification = {
specificationId: specId,
articleId: $('#articleid_' + specId).attr('value'),
price: $('#price_' + specId).attr('value'),
stock: $('#stock_' + specId).attr('value'),
stockCount: $('#stockcount_' + specId).attr('value'),
weight: $('#weight_' + specId).attr('value'),
visible: $('#visible_' + specId).attr('checked')
};
params.list.add(specification);
});
console.log(params);
//all values are parsed fine here, shows an array with json objects
$.ajax({
type: "POST",
url: "/Admin/Product/Save/",
data: params,
success: function () { alert('done'); }
});
Run Code Online (Sandbox Code Playgroud)
现在这必须像这样去控制器: …
c# ×3
.net ×1
android ×1
asp.net-mvc ×1
clickonce ×1
iis-express ×1
jquery ×1
mvvm ×1
mvvm-light ×1
soap ×1
unit-testing ×1
wpf ×1