4

I need to use MemoryMappedFile class in .net 3.5... is there any way to find the code of the classes used in .net 4.0 and create to use in .net 3.5? thanks in advance

ghiboz
  • 7,863
  • 21
  • 85
  • 131

3 Answers3

4

If you need memory mapped files in .NET 3.5, you could also write your own wrapper around the respective Win32 methods from scratch. This might take a bit more effort, but it avoids any licensing issues.

Malte Clasen
  • 5,637
  • 1
  • 23
  • 28
3

.NET 4 uses a whole new CLR, and I wouldn't be at all surprised to find that enough had changed under the hood to make this basically infeasible.

Basically, you should be working to use a version of .NET that supports the functionality you need - any workaround you find is very likely to cause hard-to-diagnose issues, IMO.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • 1
    Tell that to the SharePoint team. I'd love to use .NET 4, but as long as SharePoint is 3.5 only, I have to arrange with it. I wouldn't be surprised if the original poster has similar constraints. – Malte Clasen Aug 04 '11 at 12:51
  • @Malte: I think if I were forced like this, I'd try to separate out the processes into "ones which need SharePoint" and "ones which need .NET 4" - but it depends on the exact context, of course. – Jon Skeet Aug 04 '11 at 12:56
1

You could use a decompiler or the shared source (links omitted on purpose) to get the code. A quick look doesn't reveal any calls into the CLR, but it looks everything is "plain" C# and some P/Invoke to Win32.

However, note that you would have to pull quite some classes to make it possible, not only those of System.IO.MemoryMappedFiles. And in the end you could still run into issues as described by Jon.

Not to speak of any licensing issues, of course. Which would honestly be the first showstopper anyhow.

Christian.K
  • 47,778
  • 10
  • 99
  • 143