Simplest way to make cross-appdomain call?

If you created an object in another domain e.g. with AppDomain.CreateInstanceAndUnwrap, all you need to call the object in another domain is to call an object’s method. The simplest way to make a cross-application domain call is just to make a call directly on that object, which actually is exposed from another domain via its … Read more

How to call managed code from unmanaged code?

Look at this solution: https://sites.google.com/site/robertgiesecke/Home/uploads/unmanagedexports The solution allows to call C# function from C by decorating your function with [DllExport] attribute (opposite of P/Invoke DllImport). Exmaple: C# code class Test { [DllExport(“add”, CallingConvention = CallingConvention.StdCall)] public static int Add(int left, int right) { return left + right; } } C code: extern “C” int add(int, … Read more

What is the maximum length of a C#/CLI identifier?

In addition to the other answers, the maximum identifier length that is accepted by the Microsoft Visual C# compiler is 511 characters. This can be tested with the following code: class Program { private static void Main(string[] args) { int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = 5; } } The length of the variable name there is 511 characters. … Read more

Unable to load SqlServerSpatial.dll

I had the same problem on a Windows Server 2012 machine. It had an SqlServerSpatial110.dll file in \Windows\System32, but no SqlServerSpatial.dll. The solution was installing the Microsoft System CLR Types for SQL Server 2008 R2 on the machine. http://www.microsoft.com/en-us/download/details.aspx?id=26728 Click Download Check off one of these depending on your processor architecture: 1033\x64\SQLSysClrTypes.msi 1033\x86\SQLSysClrTypes.msi 1033\IA64\SQLSysClrTypes.msi Click … Read more

Are static indexers not supported in C#? [duplicate]

No, static indexers aren’t supported in C#. Unlike other answers, however, I see how there could easily be point in having them. Consider: Encoding x = Encoding[28591]; // Equivalent to Encoding.GetEncoding(28591) Encoding y = Encoding[“Foo”]; // Equivalent to Encoding.GetEncoding(“Foo”) It would be relatively rarely used, I suspect, but I think it’s odd that it’s prohibited … Read more

Equivalent of Class Loaders in .NET

The answer is yes, but the solution is a little tricky. The System.Reflection.Emit namespace defines types that allows assemblies to be generated dynamically. They also allow the generated assemblies to be defined incrementally. In other words it is possible to add types to the dynamic assembly, execute the generated code, and then latter add more … Read more