raddesso
raddesso

Reputation: 169

System.Runtime.InteropServices.COMException in System.Windows.Forms.dll

I am using a dll component called wnvhtmlconvert to generate pdf from html. It was working curretly last week, then now it started to get a COMException only when i am debbuging.

Bellow the output error:

An exception of type 'System.Runtime.InteropServices.COMException' occurred in System.Windows.Forms.dll and wasn't handled before a managed/native boundary

Additional information: Unknown error.

On another machine it work's normally when debbuging and published.

I have already tried to registry the wnvhtmlconvert.dll but it is not possible problably because it mustn't be registrable.

Any suggestion?

TY

Upvotes: 1

Views: 4236

Answers (3)

Ashok Garg
Ashok Garg

Reputation: 73

Go to Tools/Options/Debugging/General in Visual Studio. Uncheck Break when exceptions cross AppDomain or managed/native boundries...

Upvotes: 0

carlupq
carlupq

Reputation: 328

You have one of your debugging options set improperly for dealing with native code debugging. You can try toggling a few of those options to stop the behavior, or you can reset your debugging options back to the installation defaults by performing the following (based upon VS 2015 - PROCEED AT YOUR OWN RISK!):

  1. Make sure no instances of Visual Studio are running and Launch Visual Studio
  2. Navigate menu options TOOLS>IMPORT AND EXPORT SETTINGS...
  3. From the Wizard, select RESET ALL SETTINGS and click NEXT (don't worry, we will save your settings and reimport all of them EXCEPT Debug settings)
  4. Choose option YES, save current settings and click NEXT (all your original settings are now backed up)
  5. Your default environment should be selected, but choose the correct environment if you see otherwise i.e. 'Visual C#'and click FINISH. Settings will now be saved
  6. Using Visual Studio, navigate menu options FILE>OPEN>FILE...and browse to the folder where you saved your settings.
  7. Add the extension '.XML' to your settings file and then open it in VS
  8. Navigate menu options EDIT>ADVANCED>FORMAT DOCUMENT to make it easier to read
  9. Find in your file the XML entry/text Category name="Debugger
  10. Comment out this entire section (will contain about 70 lines of PropertyValue items
  11. Save your file (now you can reimport all your original settings without the defunct debugger settings)
  12. Navigate menu options TOOLS>IMPORT AND EXPORT SETTINGS...
  13. From the Wizard, select IMPORT...SETTINGS and click NEXT
  14. Choose NO, JUST IMPORT SETTINGS option and click NEXT
  15. Select the MY SETTINGS>CurrentSettings.vssettings list item and click BROWSE
  16. Change your browse filter (bottom right of browse window) from SETTINGS FILES to ALL FILES and browse to your settings file with the .XML extension and select/open it
  17. Click NEXT and your options will be imported. You may see an error or two, but this was not an issue for me.

Voila - just your debugger options have been left at the default settings! This worked for me, and I no longer see the odd behavior around the native code.

Good luck!

Upvotes: 2

bohdan_trotsenko
bohdan_trotsenko

Reputation: 5367

You probably do something in a non-UI thread, or forgot to pin a reference.

Upvotes: 0

Related Questions