Search code examples
c#.netvisual-c++gdal

Relationship between MSVC and .NET framework versions


This is a rather general question, a result of my confusion about how to compile GDAL using different versions of Microsoft Visual C++ (MSVC) and its C#-bindings. I understand that MSVC is a compiler and there are different versions (MSVC 2003, 2005, 2008, 2010, 2012). I also understand that C# is tied to the .NET framework, which is a software development framework that also comes in different versions (.NET 1.0 to 5.0).

I want to compile GDAL (because I want to use an extension not included in the SDK builds available here) to be used by C# (via its C#-bindings) using VS 2012, which version of MSVC would I have to use? I guess the answer is MSVC 2012 (same .NET framework version), but why actually? The GDAL build would create DLLs. Is the .NET framework not backwards compatible in the sense that I can use DLLs compiled with an older version of MSVC inside a C#-project that uses VS 2012?

Any enlightenment appreciated.


Solution

  • The relationship is largely irrelevant unless you're toying with C++/CLI (which it doesn't look like you are).

    C# uses native DLLs either by using P/Invoke (aka DllImport) or through COM, it doesn't matter what compiler they were made with so long as the exports are in the right format (and they're in the right ISA for the executing .NET platform).

    Using the same C++ compiler that VS ships with just saves you the trouble of hunting down alternative tools and simplifies your build process.