随笔分类 - C#&dotNet开发
摘要:From MSDN Structs differ from classes in several important ways: Structs are value types (Section 11.3.1).All struct types implicitly inherit from the class System.ValueType (Section 11.3.2).Assignment to a variable of a struct type creates a copy of the value being assigned (Section 11.3.3).The de.
阅读全文
摘要:首先,关于GC:1. 它不是基于引用计数的。那是COM用的东西,不够强壮而且expensive。2. 只要一个对象有一个reference还在,它肯定不会被GC干掉;但是一个没有任何reference的对象,也只能成为一个candidate tobedeleted object对于GC而言。3. GC.collect()可以被显式调用,并且确实可以做些事情,但是,不一定能干掉你想要干掉的对象,因为它只是一个candidate。4. GC只有在memory pressure的时候才会开始干活。对于weak reference而言:1. 个人认为它的适用场合是: 1)创建这个对象很贵,并且对象很占
阅读全文
摘要:Function object, also called functor, functional, or functionoid,is a computer programming construct allowing an object to be invoked or called as though it were an ordinary function, usually with the same syntax.Several notes for it:1. In C, there is only function pointer; in C#, there is only dele
阅读全文
摘要:线程间、进程间的同步是通过称为“信号量”signal的一类对象来实现的。下面是一个来自msdn的natice code world的列表:Name Relative speed Cross process Resource counting Supported platforms Critical Section Fast No No (exclusive access) 9x/NT/CE Mutex Slow Yes No (exclusive access) 9x/NT/CE Semaphore Slow Yes Automatic 9x/NT Event Slow Yes Yes 9x/
阅读全文
摘要:As known,dotnet assembly可以JIT或者用NGEN直接生成汇编级assembly来一劳永逸。对于进一步加深理解,需要记住:1. 对于JIT来说:一,它是方法级的compile;二是,只有一个assembly的所有代码都被调用过了,这个assembly才被彻底编译了一遍;第三,JIT对一个assembly的一个调用方法,在app未重新启动的情况下只做一次(点了两点:JIT的编译结果是一个存放在内存里的映射表方法名,实际函数地址;因此,app每启动一次,都要重新建)2. 对于NGEN来说,他的结果是放到GAC里的(?)。 参考:.net你怎么这么慢
阅读全文
摘要:System.Text.EncodingSystem.Text.ASCIIEncodingSystem.Text.UnicodeEncodingSystem.Text.UTF32EncodingSystem.Text.UTF7EncodingSystem.Text.UTF8Encoding参见:Character Encoding in the .NET Framework
阅读全文
摘要:GAC解决的问题是dotnet assembly如何共享assembly的问题,比如dotnet framework,肯定要部署到GAC中。注:dotnet assembly locate rule是先找GAC,再找当前app所在的目录树(CLR will firstly search in GAC for assembly loading and then get into app specific directory / path tree)。所以,对于公用的assembly,只有一条路:就是放在GAC中。sidebyside assembly解决的是dotnet assembly 版本冲
阅读全文
摘要:项目中碰到这样一个需求:本来,一个app的plugin (pluginA.dll + pluginARes.dll)是自然的deploy到app dir里面的;但是呢,现在要把这个plugin在这个app以及基于这个app开发的一些衍生产品上共享,就必须要把它放在一个common的目录里。但是呢,这个plugin有点特殊:pluginA.dll是mixedmode C++/CLI的module,然后呢,pluginARes.dll是用C#写的纯资源的dll;由于CLR locate assembly的机制,它一般只会在app目录树和GAC里寻找,那么如果,像这里的情况一样,把pluginA +
阅读全文
摘要:总结:1. 对于native c++ world来说,Dynamic-Link Library Search Order 说的很清楚了。就是还有一个疑问:如果在任意目录建立一新folder,把一个application需要的plugin之类的dll及dependency dlls都放在里面,在load这个plugin需要的dependency dlls时 (If a DLL with dependencies is loaded by specifying a full path, the system searches for the DLL's dependent DLLs as if t
阅读全文
摘要:1. AnyCPUFirstly, there are 32bit/64bit CLR. For executables, it's up to the CPU bit to decide whether it will load as a 32/64bit process with corresponding CLR; for assembly, it's up to the process i...
阅读全文
摘要:Basic1. VS has only x32bit version, NO x64 version.2. DotNet Framework including basic library (System.*), CLR, JIT compiler, etc, have x32 and x64 version. For example, I have a C:\Windows\Microsoft....
阅读全文
摘要:I met a VS out-of-date compiling issue. The situation is:1. It appear all the time if compiling a VS2010 C++/CLI project. After a successful build, press F5 to run it, prompt me: out of date! after us...
阅读全文
摘要:1. On VS2010, VC project builds with MSBuild (vcxproj) to get a consistent building system for all languages.2. No matter which platformtoolset is selected (v100 or v90), MSBuild is used for building ...
阅读全文
摘要:C# contains a struct called Intptr, which aims to be the same position as void* in unmanaged world. So it will be 32bit on x32 hardware and OS and be 64bit on x63 platform. So be careful about misusin...
阅读全文
摘要:MSDN Returns a string array containing the command-line arguments for the current process.Input at the command lineResulting command line argumentsMyApp alpha betaMyApp, alpha, betaMyApp "alpha with s...
阅读全文
摘要:Configure to make a app run against the same dotNet FrameworkFor every app, if it has assemblies that are built based on dotNet framework, then it can have a app.exe.config file to support a applicati...
阅读全文
摘要:I recently met a issue that: when starting our app by command line way (passing several arguments to the app), on Win7, the specified file can always be opened after lanuching our app, while on XP, th...
阅读全文
摘要:调用Dispose方法As known, for C#, it will call IDispose::dispose() of a class to release resources, while for C++/CLi, it needs call "delete obj" to the same work. A fact is that: no matter a dotNet class ...
阅读全文
摘要:We are so used to adding dotNet module references and project references, but rarely meet situations requiring adding other dotnet module directly. The Other dotnet module consists of 3 kinds: --preco...
阅读全文
摘要:1. C# VS COM---------directly add the COM tlb as reference and then make use of com class just like native dotNet class. 2. C# VS unmanaged module------------PInvoke. More about PInvoke: System.Runtim...
阅读全文

浙公网安备 33010602011771号