clr

Serial Port (rs232) in Mono for multiple platforms

萝らか妹 提交于 2019-12-01 08:48:41
I am planning on re-writing a Win32 application (native C++) in .NET - most likely using mono so I can run it on Win32, Linux and mac. The problem I am trying to solve (having only really developed for Win32) is an issue with the serial port definition. How does one typically identify differences in platform when there is only supposed to be one executable. Specifically, the COM port is identified in windows as COM1 or something like that (\.\COM) but on linux they are specified as something like /dev/ttyS0. Does one check the platform at runtime for this information? I think the only

CorFlags.exe, System.Data.SQLite.dll and BadImageFormatException

徘徊边缘 提交于 2019-12-01 07:48:01
Running CorFlags.exe against System.Data.SQLite.dll from http://sqlite.phxsoftware.com/ produces the following output. Version : v2.0.50727 CLR Header: 2.5 PE : PE32 CorFlags : 24 ILONLY : 0 32BIT : 0 Signed : 1 As you can see, 32BIT is not specified and PE is equal to PE32 . According to Moving from 32-bit to 64-bit application development on .NET Framework , this means that the assembly is Any CPU . However, using the assembly from a 64 bit application results in an error: System.BadImageFormatException: Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. An

Multidimensional arrays do not implement IEnumerable<T>, or do they?

这一生的挚爱 提交于 2019-12-01 07:43:59
For the reasons that I still do not understand ( see this SO question ) multidimensional arrays in CLR do not implement IEnumerable<T> . So the following does not compile: var m = new int[2,2] {{1, 2}, {3, 4}}; var q = from e in m select e; Then how come that this works just fine in VB.NET ? Sub Main() Dim m(,) As Integer = {{1, 2}, {3, 4}} Dim q = From e In m Select e For Each i In q Console.WriteLine(i) Next End Sub Update: The following code works because the C# compiler replaces the foreach with for loops to go through each dimension. foreach(var e in m) Console.WriteLine(e); becomes int[,

What exactly happens when you run a .NET executable (step by step to the point where the program is loaded and running)?

浪子不回头ぞ 提交于 2019-12-01 07:34:39
When you run a .NET executable, what exactly takes place, step by step in order. My basic understanding is that you run the executable, the CLR does some checking, compiles the CIL it into platform specific code, loads it up along with the specified required dll's (as specified in the manifest(s)) and runs your program. Can someone elaborate on this, down to the "it allocates memory for this and that" level? I would really like to know what is happening from when you double-click on the executable to when your program is successfully running. P.S. diagrams, external links welcome. :-) There's

When does the CLR try to load a referenced assembly?

☆樱花仙子☆ 提交于 2019-12-01 06:53:01
I want to write a small installer app that installs a web site and creates IIS virtual directories. The app should run on Windows XP/Server 2003 (IIS 6) as well as on Vista/2008 (IIS 7). The problem is: for IIS 6 we create virt dirs by calling WMI/Metabase API, for IIS 7 there is a much better API: Microsoft.Web.Administration, but its assembly is available only on IIS 7 systems. Naive approach: ... if (OperatingSystem == old) { call metabase API... } else { call Microsoft.Web.Administration... } ... Nice, isn't it? But how can I make sure that this does not crash on a old system just while

array/object keys for hashtables in powershell

笑着哭i 提交于 2019-12-01 06:24:05
问题 When creating a hash with an array key, How do i generate a key to look up the hash value. that is, without getting it from the hash's enumerator $a = @{"a" = "1" "b" = "2" ("c","c1") = "3"} Using a regular array, doesn't seem to work. $k1 = @("c","c1") $a.ContainsKey($k1) #false However, if the array object is used on creation, this seems to work. $k1 = @("c","c1") $a = @{"a" = "1" "b" = "2" $k1 = "3"} $a.ContainsKey($k1) #true if for example, i use this to generate a hashtable: $a = Get

CLR/Fastcall: How are large value types passed internally to called functions?

久未见 提交于 2019-12-01 06:01:20
问题 Just out of curiosity: value types are generally copied, and the JIT compiler seems to use Microsoft's Fastcall calling convention when calling a method. This puts the first few arguments in registers, for fast access. But how are large value types (i.e. bigger than the size of a register or the width of the stack) passed to the called function? This book excerpt states that: The CLR's jitted code uses the fastcall Windows calling convention. This permits the caller to supply the first two

Error message in XSLT with C# extension function

╄→尐↘猪︶ㄣ 提交于 2019-12-01 05:52:32
I am received the following error while trying to implement a C# extension function in XSLT. Extension function parameters or return values which have CLR type 'Char[]' are not supported.** code: <xsl:variable name="stringList"> <xsl:value-of select="extension:GetList('AAA BBB CCC', ' ')"/> </xsl:variable> <msxsl:script language="C#" implements-prefix="extension"> <![CDATA[ public string[] GetList(string str, char[] delimiter) { ... ... return str.Split(delimiter, StringSplitOptions.None); } ]]> </msxsl:script> Can someone explain this error message and how to get past it? EDIT: I need a

Thread order execution?

久未见 提交于 2019-12-01 05:48:12
I have this simple code : ( which i run in linqpad ) void Main() { for ( int i=0;i<10;i++) { int tmp=i; new Thread (() =>doWork(tmp)).Start(); } } public void doWork( int h) { h.Dump(); } the int tmp=i; line is for capture variable - so each iteration will have its own value. 2 problems : 1) the numbers are not sequential , while thread execution is ! 2) sometimes i get less than 10 numbers ! here are some executions outputs: questions : 1) why case 1 is happening and how can i solve it ? 2) why case 2 is happening and how can i solve it ? It should not be expected that they are sequential.

Serial Port (rs232) in Mono for multiple platforms

限于喜欢 提交于 2019-12-01 05:37:00
问题 I am planning on re-writing a Win32 application (native C++) in .NET - most likely using mono so I can run it on Win32, Linux and mac. The problem I am trying to solve (having only really developed for Win32) is an issue with the serial port definition. How does one typically identify differences in platform when there is only supposed to be one executable. Specifically, the COM port is identified in windows as COM1 or something like that (\.\COM) but on linux they are specified as something