Answered C# dynamic delima

  • Monday, April 16, 2012 12:32 PM
     
     

    Hi,

    The problem I have is a little confusing :

    My company is unbelievably stuck to Windows XP SP2,,,  Yes SP2,,, and our web hosted app works ONLY with IE6 without errors and problems.

    I am trynig to make a C# app that interact with the IE window and does some operations on the page shown, The problem is ::

    I did the application SUCCESSFULLY on a VS2010 with C# 4.0 ... Thanks to the "dynamic" keyword

    When tetsting the application on my machine (XP SP 3) which has IE 7 on it,, it worked with no problems...

    When trying to run the app on an XP SP2 machine,, it just wouldn't find the IE window at all..

    As I was thinking of a workaround this, I thought I have the following options::

    1- Install VS 2010 on a machine with XP SP2 ,,,, to be able to test and debug.,,, Minimum requirements not met.

    2- Install IE6 on the machine with XP SP3 ,,, tried it with no success.

    3- Magically find a way to use .Net 4.0 with VS 2008 ... Sadly, magic does not exist AFAIK..

    So  , Any suggetions on which route should I go ,, and how to do any of the options , particularly option No. 1

    Thanks in advance.

All Replies

  • Monday, April 16, 2012 12:53 PM
     
     
    • Option 1 is impossible... If your PC doesn't meet minimum requirements, you cannot install Visual Studio 2010.
    • Option 3 is impossibile too. To use .NET 4.0, you need Visual Studio 2010
    • The only option you can try is the number 2: take a look to this post: http://tredosoft.com/IE7_standalone.

    Marco Minerva [MCPD]
    Blog: http://blogs.ugidotnet.org/marcom
    Twitter: @marcominerva

  • Monday, April 16, 2012 1:01 PM
     
     

    Maybe you can also provide some details about the lines that do not work. How do you search for Internet Explorer windows? Which errors occur?

  • Monday, April 16, 2012 1:19 PM
     
      Has Code

    All that shows up is a dialouge box with 3 options ,, Quit ,, Continue,, and details,,

    And in the details it says that an error is happening in Line 165 which is in the top of REGEX section..

    Any way the code to find IE windows is the following :

    IEnumerable<dynamic> FindAllIE()
            {
                var t = Type.GetTypeFromProgID("Shell.Application");
                dynamic o = Activator.CreateInstance(t);
                try
                {
                    var ws = o.Windows();
                    for (int i = 0; i < ws.Count; i++)
                    {
                        var ie = ws.Item(i);
                        if (ie != null && System.IO.Path.GetFileName((string)ie.FullName) == "IEXPLORE.EXE")
                            yield return ie;
                    }
                }
                finally
                {
                    Marshal.FinalReleaseComObject(o);
                }
            }

    
     If I could find/use an equivalent way to do the job without using the "dynamic" keyword ,, I will be able to use the code in VS2008 on XP SP 2 and I think this can solve my problem.. somehow
  • Monday, April 16, 2012 1:24 PM
     
      Has Code

    Hi, Thanks for reply...

    Regarding option 1 I have came across an article that mentioned it is possible but didn't say how,, eventhough all other forums says it is IMPOSSIBLE

    http://forums.devshed.com/net-development-87/installing-net4-vs2010-on-win-xp-sp2t-727193.html
    

    See first Post Please,,

    And this leaves me quistioning if there is really a trick to install VS 2010 on XP SP 2

    Thanks in advance,,

  • Monday, April 16, 2012 1:33 PM
     
     

    Windows XP SP2 is not ufficially supported by Visual Studio 2010, so even if there is any trick to install it, I don't recommend this solution. You could manage to install it, but there could be problems running the IDE on a platform on which it isn't been tested. As you can read in the post, there could be "modules in SP3 that .NET 4 relies upon".


    Marco Minerva [MCPD]
    Blog: http://blogs.ugidotnet.org/marcom
    Twitter: @marcominerva

  • Monday, April 16, 2012 1:33 PM
     
     

    Hi, 

    The official documentation from Microsoft mention minimum requirement to install VS2010 is windows XP SP3

    http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-csharp-express


    If this post answers your question, please click "Mark As Answer". If this post is helpful please click "Mark as Helpful".

  • Monday, April 16, 2012 1:36 PM
     
     
    I have read that and I am aware of the consequences, so I am explring my other options right now
  • Monday, April 16, 2012 1:38 PM
     
     

    I am aware of that fact and I have pointed it in my first post in bold fonts.

    Thanks for the reply.

  • Monday, April 16, 2012 2:00 PM
     
     Answered

    See if another method of finding Internet Explorer windows can be used in your case: http://omegacoder.com/?p=63. Make a small program and run it in Windows XP SP2.

  • Monday, April 16, 2012 2:07 PM
     
     

    This option is the one that I have no idea on how to do it,,

    The dynamic keyword makes interop and COM a piece of cake as you may have noticed already, but doing this without using dynamic is something that i have not came across before and do not know where to start,,

    If you have any idea on how to convert the code I posted up ,, to a code usable in VS2008 (without using dynamic) this would be so helpfull

    Thanks again for your help so far,, the link is being navigated to,, thanks again