Tag: .net

无法在Octokit.net中将存储库内容作为.zip文件(zipball)获取

我使用Octokit.net version 0.9.0 (GitHub API for .NET)获取少量存储库的zip内容。 我已经有了我需要的存储库列表但是我无法将存储库的内容作为.zip文件(称为zipball)获取 到目前为止我尝试过的 // … client = new Client(…); // some authentication logic… // some other queries to GitHub that work correctly var url = “https://api.github.com/repos/SomeUser/SomeRepo/zipball”; var response = await this.client.Connection.Get( new Uri(url), new Dictionary(), null); var data = response.Body; var responseData = response.HttpResponse.Body; 我尝试的问题 data为空 responseData.GetType().Name表示responseData的类型为string 当我尝试Encoding.ASCII.GetBytes(response.HttpResponse.Body.ToString()); 我得到无效的zip文件 […]

Control.invoke和父控件

可以说我有一个名为MainForm的表单,并对其进行控制:somelabel。 为了从另一个线程访问这些控件,我必须使用Invoke方法。 例如: somelabel.Invoke(…); 但是我也可以通过以下forms访问标签 : MainForm.Invoke(…) //Code for manipulating somelabel 这两个片段在性能或其他技术方面有什么区别吗?

在JSON.NET中修剪json字符串

我使用JObject.ToString()方法将JSON对象转换为字符串。 但是如何修剪输出以删除标记之间的空格?

使用会话自定义RoleProvider

我正在考虑使用自定义MembershipProvider / RoleProviders。 不幸的是,我们目前拥有的安全层需要设置一些会话内容。 因此,当调用IsUserInRole()方法时,Session对象始终为null,因为Session内容都是预先填充的。 关于如何解决这个问题以及保留使用基于会话的安全模型的任何建议? (我没有写它,我必须使用它)。 任何帮助一如既往地非常感谢。

如何使用c#/ VB.NET在word中插入书签

我正在尝试使用C#在word文档中添加书签,但它不起作用,我在msdn文档和互联网上都找不到任何帮助。 这是我想要做的。 我正在阅读word文档,然后在该文档中搜索关键字,然后将该文本转换为超链接,并且效果很好。 现在,我想将该文本创建为书签而不是超链接。 我在C#中做这一切

.NET不会在PATH中搜索我的C#DLL

我有一个C#dll说dll1被另一个C#dll引用dll2引用。 dll1的路径在env变量PATH中指定。 当我尝试编译dll2时,dll2报告错误,它无法找到程序集dll1。 我不确定如何才能实现这一点我认为PATH在.Net的Dll搜索中使用。 等待一些有用的建议 谢谢Karandeep Malik

无法对ContainsGenericParameters为true的类型或方法执行后期绑定操作

我有一个所有实体的扩展: public static class EntityBaseExtensions { public static T Clone(this T item) where T : EntityBase { return item.EntityClone(); } } 和 public virtual T EntityClone() where T : EntityBase { return this.MemberwiseClone() as T; } 但当我称之为: var details = user.Details.Clone(); 我明白了 无法对ContainsGenericParameters为true的类型或方法执行后期绑定操作。 有任何想法吗?

Linq到Xml,保持XDocument加载?

假设我正在制作一个WinForms程序,它将在幕后使用XML文档作为持久性机制…… 以下两种方法的优缺点是什么? 在每个方法调用中加载XDocument: public class XmlFoosRepository { string xmlFileName; public XmlFoosRepository(string xmlFileName) { this.xmlFileName = xmlFileName; } public int AddFoo(Foo foo) { var xDoc = XDocument.Load(xmlFileName); // Always call Load() // … xDoc.Save(xmlFileName); return foo.ID; } public IEnumerable<Foo> GetFoos() { var xDoc = XDocument.Load(xmlFileName); // Always call Load() // … return foos; } } 要么 […]

错误:GenerateWinPRTManifest

我试图创建一个新的monogame windows phone 8项目,当我试图运行它时,我收到了这个错误: Error 1 The “GenerateWinPRTManifest” task failed unexpectedly. System.ArgumentException: An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value) at Microsoft.Silverlight.Build.Tasks.GenerateWinPRTManifest.CCIHarvestRegistrationInformation(ProcessWinmd processWinmd, Dictionary`2 inprocServers) at Microsoft.Silverlight.Build.Tasks.GenerateWinPRTManifest.UpdateWinmdRegistration() at Microsoft.Silverlight.Build.Tasks.GenerateWinPRTManifest.ExecuteImplementation() at Microsoft.Silverlight.Build.Tasks.GenerateWinPRTManifest.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.d__20.MoveNext() MonoGameWP8

保持同步和异步实现

维护方法的同步和异步版本的最佳实践是什么? Let’s suppose we have the following method: public ImportData Import(ZipFile zipFile) { … //Step 1. Initialization var extractedZipContent = zipFile.Extract(); //Step 2 … //Step 3. Some intermediate stuff var parsedData = ParseExtractedZipContent(extractedZipContent); //Step 4 … //Step 5. Some code afterwards } 第2步和第4步是长时间运行的,所以我们想在异步版本的Import方法中异步调用它们: public async Task ImportAsync(ZipFile zipFile) { … //Step 1. Initialization var extractedZipContent […]