我有以下对象:
public class ProjectInfo
{
public string ConnectionStringName { get; set; }
public string DefaultEntityNamespace { get; set; }
public string DefaultSharedNamespace { get; set; }
public string DefaultTestNamespace { get; set; }
public string SqlProviderName { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我尝试做一个简单的序列化(在VSIX项目中):
var settings = new ProjectInfo { ConnectionStringName = "SomeName" };
var json = JsonConvert.SerializeObject(settings);
Run Code Online (Sandbox Code Playgroud)
这给了我:
An exception of type 'System.IO.FileNotFoundException' occurred in Newtonsoft.Json.dll but was not handled in user code
Additional information: Could not load file or assembly …Run Code Online (Sandbox Code Playgroud) c# json.net visual-studio-extensions .net-4.5.2 visual-studio-2015
是否可以System.Collections.Generic.Dictionary在一个语句中使用String键/值对创建和初始化对象?
我正在思考一个字符串数组的构造函数.
例如
Private mStringArray As String() = {"String1", "String2", "etc"}
Run Code Online (Sandbox Code Playgroud)
如果这是一个语法糖类的东西,我更喜欢我可以在.Net 2.0(Visual Studio 2005)和Visual Basic中使用的答案 - 虽然我很好奇它是否可能如此不要让那让你失望; o)
我有一些使用HostingEnvironment.MapPath我想要进行单元测试的代码.
如何设置HostingEnvironment以便它返回路径而不是null我的单元测试(mstest)项目?
如果你认为有可能获得空指针异常,你应该使用if语句来确保变量不为null,还是应该捕获异常?
我没有看到任何区别,因为你可以把你的逻辑处理if语句或catch块中的空指针,那么哪一个是最好的做法?
这是开箱即用的mvc3库存级普通香草jquery行为?这是默认的样式行为吗?我如何使它不透明?谢谢!
<script src="../../Scripts/jquery-1.5.1.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui-1.8.11.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui-1.8.11.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$('.date').datepicker({ dateFormat: "dd/mm/yy" });
});
</script>
@Html.TextBox("xxx", "", new { @class = "date" })
Run Code Online (Sandbox Code Playgroud)

为REST apis实施身份验证的最佳实践是什么?
使用BASIC auth + SSL或类似http://tools.ietf.org/html/draft-hammer-http-token-auth-01?
是否有可用的现有解决方案(适用于.NET/WebApi)?
我想知道是否有办法从另一个指定的工作簿模块调用VBA函数或方法,因为可以在不使用Application.Run的情况下对特定工作表进行调用.
对于我可以调用的工作表,例如:
ActiveSheet.MyTest()
Run Code Online (Sandbox Code Playgroud)
如果在工作表模块中定义了MyTest
但我想调用模块中定义的函数
我试过了 :
ActiveWorkbook.MyTestModule()
ActiveWorkbook.VBProject.VBComponents("MyModule").MyTestModule(myArg)
Run Code Online (Sandbox Code Playgroud)
哪些不起作用生成错误对象不支持此方法
我可以打电话
Application.Run(ActiveWorkbook.name & "!MyTestModule", myArg)
Run Code Online (Sandbox Code Playgroud)
但我不确定Application.Run的错误处理,我会发现直接运行该方法更干净
queue1在机器A上有一个名为的公共队列.我想从机器B向此队列发送消息.为了实现这一点,我编写了c#代码.
if (MessageQueue.Exists("machineA\queue1"))
{
label1.Text = "queue found";
}
else
{
label1.Text = "queue could not be found";
}
Run Code Online (Sandbox Code Playgroud)
但是机器B上的Exists()方法返回false.相同的代码在机器C上运行良好.
我找到了与msmq域模式和工作组模式相关的东西.我认为msmq在机器B上以workgoup模式安装.
如何将此配置从工作组模式更改为域模式?
我正在尝试在vb.net应用程序中加载Visual Studio 2010(.Net framework 4)中的SOS扩展,但没有成功.
首先,我发现以下文章建议我在immidiate窗口中键入"!load sos ".它导致以下错误消息:
Error during command: extension C:\Windows\Microsoft.NET\Framework64\v4.0.30319\sos.dll could not load (error 193)
Run Code Online (Sandbox Code Playgroud)
接下来我发现了一篇建议.loadby sos clr的文章.这给了我以下错误:
Method arguments must be enclosed in parentheses.
Run Code Online (Sandbox Code Playgroud)
我该如何加载它?
我有一个目录路径C:\Subdir1\Subdir2\Subdir3\filename.xml.
在查看之前,我需要先检查文件是否filename.xml存在于"Subdir2"(一个级别)的根目录中"Subdir3".我怎样才能轻松解析这个Path.GetPathRoot(filename)?
IE
首先看看是否属实:
C:\ Subdir1\Subdir2\filename.xml中
如果不是,则默认C:\Subdir1\SubDir2\Subdir3\filename.xml为该文件.
c# ×4
.net ×2
.net-2.0 ×1
.net-4.5.2 ×1
asp.net ×1
debugging ×1
dictionary ×1
excel ×1
jquery-ui ×1
json.net ×1
memory-leaks ×1
msmq ×1
unit-testing ×1
vb.net ×1
vba ×1