假设我在当前目录中有以下文件:
buildBar.bat
buildFoo.bat
buildHouse.bat
Run Code Online (Sandbox Code Playgroud)
然后我输入我的命令提示符下,./bu然后TAB.
在Bash中,它扩展到了 ./build
在PowerShell中,它会扩展为./buildBar.bat- 列表中的第一项.
在Cmd中,行为与PowerShell相同.
我更喜欢Bash行为 - 有没有办法让PowerShell表现得像Bash.
如何使用搜索过滤器显示特定组的用户?
我尝试过以下方法:
(&
(objectCategory=user)
(memberOf=MyCustomGroup)
)
Run Code Online (Sandbox Code Playgroud)
还有这个:
(&
(objectCategory=user)
(memberOf=cn=SingleSignOn,ou=Groups,dc=tis,dc=eg,dc=ddd,D??C=com)
)
Run Code Online (Sandbox Code Playgroud)
但不显示特定组的用户.
我有一个类似的扩展方法
public static class Extension
{
public static string GetTLD(this string str)
{
var host = new System.Uri(str).Host;
int index = host.LastIndexOf('.'), last = 3;
while (index >= last - 3)
{
last = index;
index = host.LastIndexOf('.', last - 1);
}
var domain = host.Substring(index + 1);
return domain;
}
}
Run Code Online (Sandbox Code Playgroud)
我称之为
string domain = "." + _url.GetTLD();
Run Code Online (Sandbox Code Playgroud)
我在构建和清理构建时没有错误.
但我得到compilation error运行时错误说
以下方法或属性之间的调用不明确:'myignOU.Extension.GetTLD(string)'和'myIGNOU.Extension.GetTLD(string)'
我发誓我没有把这个扩展方法放在项目中的任何其他位置.为什么我只在运行时收到此错误..?
但是,如果我删除此方法,那么我在构建时遇到错误,而不是在运行时.没有这种方法的代码,一切正常.
评估typeof(Object[,][]).Name给出Object[][,]
同样,typeof(Object[][,]).Name给出Object[,][]
好像逗号正在无缘无故地移动.
是什么赋予了?
我遇到了VS 2010的问题.它运行速度非常慢,并且在编译和打包xap文件时偶尔会崩溃并出现以下错误:
Xap packaging failed. Exception of type 'System.OutOfMemoryException' was thrown.
Run Code Online (Sandbox Code Playgroud)
在本地Windows 7临时目录中\Users\usernamexxxx\AppData\Local\Temp
有数千个文件,因此我将其删除,现在VS速度更快.
还有其他人有类似的问题吗?
silverlight compiler-errors visual-studio-2010 xap windows-7
我有两个组件:App和AddOn. App引用AddOn,但CopyLocal设置为false,因为AddOn将动态加载App.
这是以下代码AddOn:
namespace AddOn
{
public class AddOnClass
{
public static void DoAddOnStuff()
{
Console.WriteLine("AddOn is doing stuff.");
}
}
}
Run Code Online (Sandbox Code Playgroud)
这里的代码是App:
class Program
{
static void Main(string[] args)
{
Assembly.LoadFrom(@"..\..\..\AddOn\bin\Debug\AddOn.dll");
// Without this event handler, we get a FileNotFoundException.
// AppDomain.CurrentDomain.AssemblyResolve += (sender, e) =>
// {
// return AppDomain.CurrentDomain.GetAssemblies()
// .FirstOrDefault(a => a.FullName == e.Name);
//};
CallAddOn();
} …Run Code Online (Sandbox Code Playgroud) 我正在设计一个供公众使用的.NET API.在我的API中,有一堆枚举,我正在努力决定用于后缀的约定.
在.NET框架中,我看到使用"Kind"(例如System.DateTimeKind)以及"Type"(例如System.IO.DriveType)的示例.
查看mscorlib中的公共枚举,我看到"Type"被更频繁地使用,但两者仍然在一些较新的类型上使用,这意味着它看起来像Microsoft没有遵循任何特定的约定.
有没有人建议我在API中使用什么?是否有任何已发布的公约涵盖此主题?
我倾向于使用"Kind"作为后缀,并保留术语"Type"来处理System.Type对象或数据类型.
我有这个小问题,我无法弄清楚要传递给Type.GetMethod的哪些参数,以便在非泛型类型上返回泛型方法的MethodInfo.具体来说,我有这种类型的定义:
public static class A
{
public static B F<T>(bool dummy)
{
}
public static B F<T>(IEnumerable<T> arg)
{
...
}
}
Run Code Online (Sandbox Code Playgroud)
我在Type.GetMethod上尝试了几次,但没有人会返回F方法的MethodInfo.
我知道我可以调用Type.GetMethods甚至Type.FindMember,但我对Type.GetMethod感兴趣.
有任何想法吗?
谢谢.
编辑
实际上,我的代码有点复杂.泛型方法被重载,因此我不能仅使用函数名称来使用Type.GetMethod.我试过这些变种:
typeof(A).GetMethod("F", BindingFlags.Static | BindingFlags.Public, null, new Type[]{ typeof(IEnumerable<>) }, null)
typeof(A).GetMethod("F`1", BindingFlags.Static | BindingFlags.Public, null, new Type[]{ typeof(IEnumerable<>) }, null)
typeof(A).GetMethod("F[T]", BindingFlags.Static | BindingFlags.Public, null, new Type[]{ typeof(IEnumerable<>) }, null)
typeof(A).GetMethod("F[[T]]", BindingFlags.Static | BindingFlags.Public, null, new Type[]{ typeof(IEnumerable<>) }, null)
Run Code Online (Sandbox Code Playgroud) 我最近开始在Visual Studio中的项目中使用代码分析.我创建了一个自定义规则集,用于包含两个Microsoft定义的规则集的所有项目.我一直在努力将FxCop集成到CI构建过程中,以使未通过所有规则的构建失败.对我来说真正奇怪的是我不能使用我的规则集来定义FxCop扫描代码的规则.我如何使Visual Studio的代码分析规则符合FxCop的规则?
我正在使用 .NET 从 URL 下载数据。对于大多数 URL,它都没有问题,但对于一个特定的 URL,当我尝试建立连接时,我收到一个非常奇怪的错误。此外,该错误仅在第二次(及后续)尝试发出请求时发生。第一次似乎总是有效。
这是一些演示该问题的示例代码:
string url = "https://health-infobase.canada.ca/src/data/covidLive/covid19.csv";
for (int i = 1; i <= 10; i++)
{
var req = (HttpWebRequest)WebRequest.Create(url);
// Just in case, rule these out as being related to the issue.
req.AllowAutoRedirect = false;
req.ServerCertificateValidationCallback = (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) => true;
try
{
// This line throws the exception.
using (req.GetResponse()) { }
}
catch (Exception ex) {
Console.WriteLine(ex.ToString());
Console.WriteLine($"Failed on attempt {i}.");
return;
}
}
Run Code Online (Sandbox Code Playgroud)
注意事项 …
.net ×6
c# ×4
reflection ×3
.net-core ×1
ambiguous ×1
api ×1
asp.net ×1
cmd ×1
fxcop ×1
https ×1
ldap ×1
ldap-query ×1
methodinfo ×1
powershell ×1
schannel ×1
silverlight ×1
ssl ×1
teamcity ×1
windows-7 ×1
xap ×1