C#: Unable to cast object of type ‘System.Int64’ to type ‘System.Int32’
You must first unbox the value as the dictionary’s value type is object. Dictionary<object, object> dict = … Color = (int)(long)dict.GetValue(“color”);
You must first unbox the value as the dictionary’s value type is object. Dictionary<object, object> dict = … Color = (int)(long)dict.GetValue(“color”);
The answer is pretty obvious: because you want to use .Net on Linux. This of course begs the question (which I think is really what you’re getting at): why would you want to use .Net on Linux (over Java)? Lots of reasons: Common code between your server and, say, a WPF or Winforms app; Use … Read more
Yes, monodis is Mono’s equivalent for ildasm. $ cat a.cs public class Foo { public static void Main() { System.Console.WriteLine(“Hello world”); } } $ monodis a.exe .assembly extern mscorlib { .ver 1:0:5000:0 .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. } .assembly ‘a’ { .hash algorithm 0x00008004 .ver 0:0:0:0 } … Read more
Gmail’s SMTP server requires you to authenticate your request with a valid gmail email/password combination. You do need SSL enabled as well. Without actually being able to see a dump of all your variables being passed in the best guess I can make is that your Credentials are invalid, make sure you’re using a valid … Read more
We don’t have a compiler for C++/CLI, it would be a very large undertaking for a very small userbase. Consider also that the C++/CLI spec is inherently flawed and non-portable, so being able to compile it wouldn’t help much in the general case. You can compile using the MS .NET compiler and run in mono … Read more
Try to match version numbers that span a whole line: $ strings file.exe | egrep ‘^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$’ In my (few) tests, the AssemblyVersion of the binary was always the last result.
Use the is keyword and reflection. public bool IsList(object o) { if(o == null) return false; return o is IList && o.GetType().IsGenericType && o.GetType().GetGenericTypeDefinition().IsAssignableFrom(typeof(List<>)); } public bool IsDictionary(object o) { if(o == null) return false; return o is IDictionary && o.GetType().IsGenericType && o.GetType().GetGenericTypeDefinition().IsAssignableFrom(typeof(Dictionary<,>)); }
LINQPad doesn’t work in Mono primarily because it relies on ActiPro’s SyntaxEditor which does some Win32 interop. LINQPad itself also does some interop. An early prototype of LINQPad used a TextBox instead of a syntax editor – this might be what was tested against Mono.
The Mono compiler defines __MonoCS__ BUT, BUT, BUT, the whole point of Mono is that you can take an assembly that you built with VS and run it on Mono, or vice versa. It seems to me that if you need to have Mono vs MS.NET differences, then you need to be making those decisions … Read more