none
Using different version of assemblies (Microsoft.ReportViewer.WebForms) RRS feed

  • Question

  • Hi Guys, 

    I need to use different versions of Microsoft.ReportViewer.WebForms(Version=9.0.0.0 and Version = 10.0.0.0) in a web application. Developed two user controls, one for each version of the report viewer. and loading it dynamically. But confused about the entries in the web.config. How do I define the handlers for both? ( using classic mode)

    Thanks,

    nasayoo


    nasayoo

    Monday, January 12, 2015 4:52 PM

Answers

  • Hello,

    >>. But in case of Report viewer control, we have to register the http handlers for that. and only one can be added at a time. So how do I deal with this?

    It is my mistake I do not notice that it would be a control rather than a pure assembly. After searching more, it seems that we can have only one and cannot register the handler at runtime. Anyway, I would share my searching result, not sure if we can register two different version assembly handlder since I am not experienced with this control and do not test it but I think it might be helpful to you:

    ASP.NET - Dynamically register an HttpHandler in code (not in web.config) [duplicate]

    Another suggestion is that you could write two separate class libraries to warp the two different version with same identify assemblies and reference the two libraries in your web application, this is based on my understand about .NET assemblies, I am not sure it works since this assembly is a control which needs to be registered, you could have a try anyway.

    By the way, since this issue seems to be related with web config, I think the web related forum should be appropriate for this issue and there are many web experts who would help you better about web issues.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, January 14, 2015 6:15 AM
    Moderator

All replies

  • Hello nasayoo,

    Since you want to load two different version assemblies to one application, according to this article, loading without context is the only way to load multiple assemblies that have the same identity into one application domain. The cost of probing is avoided. One of the way to load assembly without any content is to use the Assembly.LoadFile() method, and I  made a sample demo, you could check it:

    Assembly m_Assembly1 = Assembly.LoadFile(@"D:\BMX\Project\2015\CLRs\CLR\bin\Debug\Old Version\Some.dll");
    
                    Assembly m_Assembly2 = Assembly.LoadFile(@"D:\BMX\Project\2015\CLRs\CLR\bin\Debug\New Version\Some.dll");
    
    
                    Console.WriteLine("Old Version: " + m_Assembly1.FullName);
    
                    Console.WriteLine("New Version: " + m_Assembly2.FullName);
    
    
                    object m_OldObject = m_Assembly1.CreateInstance("Some.Class1");
    
                    object m_NewObject = m_Assembly2.CreateInstance("Some.Class1");
    
    
                    Type t1 = m_OldObject.GetType();
    
                    t1.GetMethod("Print").Invoke(m_OldObject, null);
    
    
                    Type t2 = m_NewObject.GetType();
    
                    t2.GetMethod("Print").Invoke(m_NewObject, null);
    

    Or you could add a reference to the Old/New version one firstly by right clicking the project reference, and dynamically load the other by the Assmebly.LoadFile method. And since it is loaded at runtime, we need to use it with refection.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, January 13, 2015 3:07 AM
    Moderator
  • Hi Fred,

    Thanks for the sample demo. I am already doing like this. But in case of Report viewer control, we have to register the http handlers for that. and only one can be added at a time. So how do I deal with this?

    Thanks


    nasayoo

    Tuesday, January 13, 2015 2:49 PM
  • Hello,

    >>. But in case of Report viewer control, we have to register the http handlers for that. and only one can be added at a time. So how do I deal with this?

    It is my mistake I do not notice that it would be a control rather than a pure assembly. After searching more, it seems that we can have only one and cannot register the handler at runtime. Anyway, I would share my searching result, not sure if we can register two different version assembly handlder since I am not experienced with this control and do not test it but I think it might be helpful to you:

    ASP.NET - Dynamically register an HttpHandler in code (not in web.config) [duplicate]

    Another suggestion is that you could write two separate class libraries to warp the two different version with same identify assemblies and reference the two libraries in your web application, this is based on my understand about .NET assemblies, I am not sure it works since this assembly is a control which needs to be registered, you could have a try anyway.

    By the way, since this issue seems to be related with web config, I think the web related forum should be appropriate for this issue and there are many web experts who would help you better about web issues.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, January 14, 2015 6:15 AM
    Moderator