Results 1 to 9 of 9

Thread: [RESOLVED] Dreaded clr20r3 System.InvalidOperationException on program start ONLY on Windows XP

  1. #1

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Resolved [RESOLVED] Dreaded clr20r3 System.InvalidOperationException on program start ONLY on Windows XP

    I'm typing this up only to document it and possibly save others the three days of frustration and hell I had to go through. Because this unhanded exception was damned near untrappable (it happens on Form.Show(), but since my primary form was affected, I couldn't tell at the time), it's one I know I lost a lot of hair nailing down.

    I have an office application. Standard fare utility program that grew to do lots of custom tricks for my place of business. Lots of database providers to pull data from various unconnected sources and crystal reports to make fancy reports from it all.

    When I make a change or addition to it, it usually is only needed by one employee, so I only deploy the new version to one computer at a time. Recently, I had to reinstall the program to the whole company. Everything was going fine, until somebody who had a Windows XP machine tried to run it. It was giving a "clr20r3" "System.InvalidOperationException" on program boot. None of my Try-Catch blocks were catching it. Any Windows XP machine I installed it on was failing, and any Vista/Win7 machine had no issues at all.

    I spent the next three days trying to catch what was causing it, pulling out references, reinstalling .NET. Searching for references to this error online was futile since System.InvalidOperationException is one of those ultra-generic errors that pop up for hundreds of oddball reasons.

    Finally, by happenstance, I found the cause via a single, obscure post on TechArena by a poster with only that post to his name who decided to chime in with his two cents on someone else's System.InvalidOperationException problem.

    About a month ago, I replaced the program icon with a new one. I made up a nice Icon, and compiled pre-sized versions of it into a proper .ICO file from 16x16 all the way up to 256x256. I replaced the program icon with it, the links to the shortcuts in the setup program, and the icon on the main form.

    THAT was the bug. Because my .ICO file had sizes larger than 64x64, Windows XP couldn't handle it as a form icon! It works fine for the program icon and for the shortcuts, but the form icons MUST be 64x64 or smaller or the program will throw System.InvalidOperationException on Form.Show(). I didn't know this was the issue since this change was over a month old and I hadn't needed to upgrade a Windows XP machine in that time. Windows Vista and 7 can handle large icon files just fine!

    Solution, I made a second, WinXP compliant icon just for the main form. Problem solved. My big icon is still used for my program and shortcuts, so they look great scaling to max size in Windows Vista/7 and XP no longer crashes with a cryptic error message.

    So, I post my story for posterity. If it even helps one other person, then it will have been worthwhile.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  2. #2
    New Member
    Join Date
    Nov 2011
    Posts
    3

    Re: [RESOLVED] Dreaded clr20r3 System.InvalidOperationException on program start ONLY

    Hi Jenner! First of all thank you for posting your story I was glad when I found this, sadly I'm still having the same error System.InvalidOperationException. In my machine everything is fine of course, but outside my pc the application crashes at start. It doesn't even show the main form. Note the other machine has Windows 7, not XP, and I'm using a virtual machine with win 7 too for the tests I'm doing right now.

    First I thought it had to do with the framework 4.0 that I was using, now I'm compiling the app in .net 3.0 for Any CPU, I'm using Windows 7, VS2010 with SQL SMS by the way...

    I have an office application too, my program recieves several .xls files to work with that information. I've tried several icons and it doesn't work, I've also tried with the default icon from VS... You are saying it must be 64x64, if I open my original icon in Paint, it says 64x64... In VS it says 32;32 Width 32 Height 32 so I don't know :| Anyway I've replaced my original icon but it doesnt work.

    Any other advice/idea?
    I've also tried with Try...Catch with the subrutine Form Load, when the main form shows up but it doesnt work... There is also a msgbox in the first line of this sub form load.

    Thanks!
    And sorry for my english!

  3. #3

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: [RESOLVED] Dreaded clr20r3 System.InvalidOperationException on program start ONLY

    Do the other machines have the Excel Interop assemblies on them and Microsoft Excel? It sounds like the icon may not be your problem.

    Can you trap the error with a Try...Catch maybe around your whole Form_Load event or something?
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  4. #4
    New Member
    Join Date
    Nov 2011
    Posts
    3

    Re: [RESOLVED] Dreaded clr20r3 System.InvalidOperationException on program start ONLY

    The machine has Microsoft Excel of course, but not Excel Interop Assemblies... I thought everything the application needed it was included in the .exe file when compiling...

    Right now I'm runing win 7 on a virtual machine with virtual box to do some tests quickly and don't ask the "client" because it will take too long...

    I've downloaded and installed Microsoft Office 2007, also oxppia.exe and also PrimaryInteropAssembly.exe wich gives you this o2007pia.msi... Reboot and tried again and don't work, still the same problem...

    Don't know if o2007pia.msi is installed correctly because it ends up very quick when it says gathering required information... In both machines, the virtual and the physical.

    I've tried with Try...Catch around the whole Form_Load event and it doesn't work... I suppose it doesn't even pass through the Imports part where I have this (just in case):

    Imports Microsoft.Office.Interop.Excel
    Imports Microsoft.Office.Interop
    Imports Microsoft.Office.Core
    Imports System.IO
    Imports System.Threading
    Imports System.Collections.SortedList
    Imports System.Windows.Forms.Form

  5. #5
    New Member
    Join Date
    Nov 2011
    Posts
    3

    Re: [RESOLVED] Dreaded clr20r3 System.InvalidOperationException on program start ONLY

    Any help? Anyone knows what do I have to install at least?

    I tried different things but nothing happens...
    Again I'm using Visual Studio 2010, SQL SMS 2008, Microsoft Excel 12.0 Object Library, with this imports...
    Microsoft.Office.Interop.Excel, Microsoft.Office.Interop, Microsoft.Office.Core

    Thanks

  6. #6
    Member
    Join Date
    Mar 2013
    Posts
    33

    Re: [RESOLVED] Dreaded clr20r3 System.InvalidOperationException on program start ONLY

    Quote Originally Posted by Jenner View Post
    I'm typing this up only to document it and possibly save others the three days of frustration and hell I had to go through. Because this unhanded exception was damned near untrappable (it happens on Form.Show(), but since my primary form was affected, I couldn't tell at the time), it's one I know I lost a lot of hair nailing down.

    I have an office application. Standard fare utility program that grew to do lots of custom tricks for my place of business. Lots of database providers to pull data from various unconnected sources and crystal reports to make fancy reports from it all.

    When I make a change or addition to it, it usually is only needed by one employee, so I only deploy the new version to one computer at a time. Recently, I had to reinstall the program to the whole company. Everything was going fine, until somebody who had a Windows XP machine tried to run it. It was giving a "clr20r3" "System.InvalidOperationException" on program boot. None of my Try-Catch blocks were catching it. Any Windows XP machine I installed it on was failing, and any Vista/Win7 machine had no issues at all.

    I spent the next three days trying to catch what was causing it, pulling out references, reinstalling .NET. Searching for references to this error online was futile since System.InvalidOperationException is one of those ultra-generic errors that pop up for hundreds of oddball reasons.

    Finally, by happenstance, I found the cause via a single, obscure post on TechArena by a poster with only that post to his name who decided to chime in with his two cents on someone else's System.InvalidOperationException problem.

    About a month ago, I replaced the program icon with a new one. I made up a nice Icon, and compiled pre-sized versions of it into a proper .ICO file from 16x16 all the way up to 256x256. I replaced the program icon with it, the links to the shortcuts in the setup program, and the icon on the main form.

    THAT was the bug. Because my .ICO file had sizes larger than 64x64, Windows XP couldn't handle it as a form icon! It works fine for the program icon and for the shortcuts, but the form icons MUST be 64x64 or smaller or the program will throw System.InvalidOperationException on Form.Show(). I didn't know this was the issue since this change was over a month old and I hadn't needed to upgrade a Windows XP machine in that time. Windows Vista and 7 can handle large icon files just fine!

    Solution, I made a second, WinXP compliant icon just for the main form. Problem solved. My big icon is still used for my program and shortcuts, so they look great scaling to max size in Windows Vista/7 and XP no longer crashes with a cryptic error message.

    So, I post my story for posterity. If it even helps one other person, then it will have been worthwhile.
    @ jenner, Im facing a similar problem, my app has a lot of graphic content, its not linked to any database and has no setup file, its just an exe that i execute for personal puposes. its working in my laptop where i created it, but it isn working in another computer of mine. both of the above computers have windows 7, .net framework 4.5 and ive used visual studio 2012 express to create it.. please help ive not been able to solve this problem from almost a month..
    its showing a "clr20r3 system.invalidoperationexception", this is the problem signature.

  7. #7

    Re: [RESOLVED] Dreaded clr20r3 System.InvalidOperationException on program start ONLY

    Where is it throwing the error? What line, exactly? That is not the only cause of that dreaded error message.

  8. #8
    Member
    Join Date
    Mar 2013
    Posts
    33

    Re: [RESOLVED] Dreaded clr20r3 System.InvalidOperationException on program start ONLY

    its showing the error at the start of the app only. How can i know which exact line its showing the error??
    What other reasons might be there for such problems to occur??
    I need to install this in 17 other computers, i want to know all the problems tht can arise before i approach my client. Please help.

  9. #9
    New Member
    Join Date
    Oct 2014
    Posts
    1

    Re: [RESOLVED] Dreaded clr20r3 System.InvalidOperationException on program start ONLY

    Quote Originally Posted by zorro1 View Post
    Hi Jenner! First of all thank you for posting your story I was glad when I found this, sadly I'm still having the same error System.InvalidOperationException. In my machine everything is fine of course, but outside my pc the application crashes at start. It doesn't even show the main form. Note the other machine has Windows 7, not XP, and I'm using a virtual machine with win 7 too for the tests I'm doing right now.

    First I thought it had to do with the framework 4.0 that I was using, now I'm compiling the app in .net 3.0 for Any CPU, I'm using Windows 7, VS2010 with SQL SMS by the way...

    I have an office application too, my program recieves several .xls files to work with that information. I've tried several icons and it doesn't work, I've also tried with the default icon from VS... You are saying it must be 64x64, if I open my original icon in Paint, it says 64x64... In VS it says 32;32 Width 32 Height 32 so I don't know :| Anyway I've replaced my original icon but it doesnt work.

    Any other advice/idea?
    I've also tried with Try...Catch with the subrutine Form Load, when the main form shows up but it doesnt work... There is also a msgbox in the first line of this sub form load.

    Thanks!
    And sorry for my english!


    zorro1

    The Issue has to do with the app.config file

    there is a specific line that crashes with only with Windows XP but works fine with W7:

    <transport>
    <extendedProtectionPolicy policyEnforcement="Never" />
    </transport>

    You need to remove the entire line (<extendedProtectionPolicy policyEnforcement="Never" />) in order to solve the XP Crash.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width