none
.NET Framework 2.0 Code Calling .NET Framework 4.0 Code RRS feed

  • Question

  • Hi,

    Is there a prescribed approach for calling .NET Framework 4.0 code from existing .NET 2.0 code directly? 

    What are the Pros and Cons of this? 

    Regards,

    Vikram


    Blog: http://dotnetupdate.blogspot.com |

    Monday, August 12, 2013 4:14 PM
    Moderator

Answers

  • Hi Vikram,

    As you know, there is no direct support to achive your requirement. If it the approach provided by Arik Poznanski does work, it's worth to have a try.

    I did review this approach and every step mentioned in that article is supported in .net programming. From your description, I think you have concerns on the free registration COM. That is a supported way. Please check this http://msdn.microsoft.com/en-us/library/fh1h056h.aspx 

    If let me say the Cons/Negatives of going with this approach, here is:

    Cons: can solve your problem, and it should be the only way can solve the problem for now if you would like to run the .net 4.0 assebmly in same process.

    Negatives: requirments for registration free COM: http://msdn.microsoft.com/en-us/library/f8h7012w.aspx . And I did see some problems about manifest when using registration free COM on different platforms.

    For production code, I think what we need to do is to perform enough tests on your targeted platforms.

    Should you have any further concerns, please feel free to let me know.

    Thanks,


    Alan Yao [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, August 14, 2013 6:20 AM

All replies

  • Either:

    1) Test and run the .NET 2.0 code in a .NET 4.0 process along with the .NET 4.0 code.  Usually .NET 2.0 assemblies will run without issue in .NET 4.0.

    2) Use WCF for interprocess communication between a process running .NET 2.0 and a process running .NET 4.0.

    In-Process Side-By-Side is not intended for this scenario.

    David


    David http://blogs.msdn.com/b/dbrowne/

    Monday, August 12, 2013 4:35 PM
  • Hi,

    Thanks David. In this scenario we are trying to load a newly developed .NET 4.0 DLL within existing (legacy) .NET 2.0 code. I am looking at the approaches covered in the articles below:

    http://blogs.microsoft.co.il/blogs/arik/archive/2011/05/30/how-to-use-a-net-4-based-dll-from-net-2-based-application.aspx

    http://www.codeproject.com/Articles/204406/How-To-Use-a-NET-4-Based-DLL-From-NET-2-Based-Appl

    Are the above mentioned approaches valid for Production Code? Is this a Microsoft supported usage of COM Interop? What are the Cons/Negatives of going with this approach?

    Regards,

    Vikram


    Blog: http://dotnetupdate.blogspot.com |

    Tuesday, August 13, 2013 10:11 AM
    Moderator
  • Hi Vikram,

    As you know, there is no direct support to achive your requirement. If it the approach provided by Arik Poznanski does work, it's worth to have a try.

    I did review this approach and every step mentioned in that article is supported in .net programming. From your description, I think you have concerns on the free registration COM. That is a supported way. Please check this http://msdn.microsoft.com/en-us/library/fh1h056h.aspx 

    If let me say the Cons/Negatives of going with this approach, here is:

    Cons: can solve your problem, and it should be the only way can solve the problem for now if you would like to run the .net 4.0 assebmly in same process.

    Negatives: requirments for registration free COM: http://msdn.microsoft.com/en-us/library/f8h7012w.aspx . And I did see some problems about manifest when using registration free COM on different platforms.

    For production code, I think what we need to do is to perform enough tests on your targeted platforms.

    Should you have any further concerns, please feel free to let me know.

    Thanks,


    Alan Yao [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, August 14, 2013 6:20 AM