Tag: .net

FIFO /队列缓冲区专门用于字节流

是否有任何.NET数据结构/类组合允许将字节数据附加到缓冲区的末尾,但所有的查找和读取都是从一开始,在我读取时缩短缓冲区? MemoryStream类似乎也是其中的一部分,但是我需要为读取和写入维护单独的位置,并且它在读取后不会自动丢弃数据。 答案已经回复了这个问题 ,这基本上就是我要做的事情,但我更喜欢我可以在同一个过程的不同组件中进行异步I / O,就像普通管道甚至是网络流(我需要先过滤/处理数据)。

如何编写自定义PowerShell主机

类似于nuget 希望在钻研调试器之前寻找任何入门材料

Marshal.AllocHGlobal VS Marshal.AllocCoTaskMem,Marshal.SizeOf VS sizeof()

我有以下结构: [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct WAVEHDR { internal IntPtr lpData; // pointer to locked data buffer internal uint dwBufferLength; // length of data buffer internal uint dwBytesRecorded; // used for input only internal IntPtr dwUser; // for client’s use internal uint dwFlags; // assorted flags (see defines) internal uint dwLoops; // loop control […]

.NET中的“,”(逗号)和“。”(点)的KeyCode是什么?

在我的KeyDown EventHandler我需要知道“,”和“。”的KeyCode是什么。 我找不到他们,这就是我要问的原因。 谢谢!

如何修复“请求的资源正在使用中。 (HRESULTexception:0x800700AA)“

我该如何解决这个错误? “请求的资源正在使用中。(HRESULTexception:0x800700AA)”。 在使用C#.NET中的WebBrowser控件导航到其他网站时出现。 为什么?

VB.NET WithEvents关键字行为 – VB.NET编译器限制?

我正在努力变得像熟悉C#一样熟悉VB.NET(我工作场所使用的语言)。 关于学习过程的最好的事情之一是,通过了解另一种语言,您倾向于更多地了解您的主要语言 – 这样的小问题会弹出: 根据我发现的消息来源和过去的经验,VB.NET中声明为WithEvents的字段能够引发事件。 我知道C#没有直接的等价物 – 但我的问题是:VB.NET中没有这个关键字的字段不能引发事件,有没有办法在C#中创建相同的行为? VB编译器是否只是阻止这些对象处理事件(实际上允许它们像往常一样引发事件)? 我只是好奇; 我对这个问题没有任何特别的申请……

无法将类型’System.Linq.IQueryable’隐式转换为’System.Collections.Generic.IList’

我有一个方法: public DzieckoAndOpiekunCollection GetChildAndOpiekunByFirstnameLastname(string firstname, string lastname) { DataTransfer.ChargeInSchoolEntities db = new DataTransfer.ChargeInSchoolEntities(); DzieckoAndOpiekunCollection result = new DzieckoAndOpiekunCollection(); if (firstname == null && lastname != null) { IList resultV = from p in db.Dziecko where lastname == p.Nazwisko **select** new DzieckoAndOpiekun( p.Imie, p.Nazwisko, p.Opiekun.Imie, p.Opiekun.Nazwisko) ; result.AddRange(resultV); } return result; } 和选定位置的错误: 错误1无法将类型’System.Linq.IQueryable ‘隐式转换为’System.Collections.Generic.IList ‘。 […]

使用InstallUtil安装具有启动参数的Windows服务

我使用InstallUtil来安装我的服务,我只是无法弄清楚如何为它指定启动参数! 这是我的Installer子类: [RunInstaller(true)] public class ServerHostInstaller : Installer { private ServiceInstaller m_serviceInstaller; private ServiceProcessInstaller m_serviceProcessInstaller; private static string s_usage = “Usage:\ninstallutil /i /username= /password= NCStub.Server.Host.exe”; public ServerHostInstaller() { m_serviceInstaller = new ServiceInstaller(); m_serviceInstaller.ServiceName = Program.ServiceName; m_serviceInstaller.DisplayName = Program.ServiceName; m_serviceInstaller.StartType = ServiceStartMode.Automatic; m_serviceProcessInstaller = new ServiceProcessInstaller(); m_serviceProcessInstaller.Account = ServiceAccount.User; Installers.Add(m_serviceInstaller); Installers.Add(m_serviceProcessInstaller); } public override void Install(IDictionary […]

HttpContext.Current在异步Callback中为null

尝试在方法回调中访问HttpContext.Current ,所以我可以修改Session变量,但是我收到HttpContext.Current为null的exception。 当_anAgent对象触发它时,异步触发回调方法。 在查看SO上的类似 问题之后,我仍然不确定解决方案。 我的代码的简化版本如下所示: public partial class Index : System.Web.UI.Page protected void Page_Load() { // aCallback is an Action, triggered when a callback is received _anAgent = new WorkAgent(…, aCallback: Callback); … HttpContext.Current.Session[“str_var”] = _someStrVariable; } protected void SendData() // Called on button click { … var some_str_variable = HttpContext.Current.Session[“str_var”]; // The agent […]

“.NET框架默认使用UTF-16编码标准”是什么意思?

我的学习指南(70-536考试)在文章和编码章节中说了两次,就在IO章之后。 到目前为止,所有示例都与使用FileStream和StreamWriter进行简单文件访问有关。 它也说“如果你不知道在创建文件时使用什么编码,请不要指定一个,.NET将使用UTF16”和“使用Stream构造函数重载指定不同的编码”。 别担心实际的重载在StreamWriter类上,但是嘿,无论如何。 我现在正在reflection器中查看StreamWriter,我确信我可以看到默认是默认的UTF8NoBOM。 但这些都没有在勘误表中列出。 这是一本旧书(对两个版本的错误进行了调整)所以如果错了,我会认为有人已经接受了…… 让我想到也许我不理解它。 那么…..任何想法,它在说什么? 其他一些有默认的地方? 这让我很困惑。