Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[C#] Funktion wird übersprungen (SystemTypeLoadException)

Empfohlene Antworten

Hi,

ich hab aktuell das Problem das eine Anwendung ständig abschmiert aufgrund einer Funktion die eine Exception auslöst. Das skurile daran ist das ich bis zu dem Aufruf debuggen kann, er aber nicht an dem Breakpoint innerhalb der aufgerufenen Funktion anhält sondern direkt die Exception wirft.

Als würde der Aufruf selbst fehlerhaft sein.

Ich habe bereits die Signaturen überprüft und diese Stimmen überein.

Nichts desto trotz erhalte ich ständig eine "System.TypeLoadException".

Hier ist der Code der Klasse:


using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Drawing;

using System.Timers;

namespace Dev86UI.FileExplorer.Windows.Components

{

    [Serializable()]

    public sealed class ExplorerEntity 

    {

        #region Fields

        private ExplorerEntityType type = ExplorerEntityType.Undefined;

        private FileNameVisibility filenameType = FileNameVisibility.Undefined;

        private EntitySizeMode entitySizeMode = EntitySizeMode.Normal;

        private ImageSizeEnum sizeMode = ImageSizeEnum.Normal;

        private string value = string.Empty;

        private string fullpath = string.Empty;

        private string preparedValue = string.Empty;

        private Icon ico;

        private Size size;

        private bool isSelected;

        private Point location;

        #endregion

        public ExplorerEntity(ExplorerEntityType EntityType, Icon ico, FileNameVisibility type, string Value, string fullpath,EntitySizeMode entitySizeMode)

        {

            this.type = EntityType;

            this.filenameType = type;

            this.value = Value;

            this.fullpath = fullpath;

            this.entitySizeMode = entitySizeMode;

            switch (entitySizeMode)

            {

                case EntitySizeMode.Large:

                    this.sizeMode = ImageSizeEnum.Large;

                    break;

                case EntitySizeMode.Normal:

                    this.sizeMode = ImageSizeEnum.Normal;

                    break;

                case EntitySizeMode.Small:

                    this.sizeMode = ImageSizeEnum.Small;

                    break;

            }

            //Bis hierhin kann ich debuggen dann steigt die Anwendung aus.

            //Die Breakpoints am Anfang von SetNewIcon werden ignoriert und

            //eine System.TypeLoadException wird geworfen.

            this.SetNewIcon(entitySizeMode, ico, EntityType);


        }

        #region Properties

        public string FullPath {

            get { return fullpath; }

            set { fullpath = value; }

        }

        public ExplorerEntityType Type {

            get { return type; }

            set { type = value; }

        }

        public string Value {

            get { return value; }

            set { this.value = value; }

        }

        internal Point Location {

            get { return location; }

            set { location = value; }

        }

        internal Size Size {

            get { return size; }

            set { size = value; }

        }

        internal string PreparedString {

            get { return preparedValue; }

            set { preparedValue = value; }

        }

        internal Icon Icon {

            get { return ico; }

            set { //ico = value; 

                SetNewIcon(entitySizeMode, value, type);

            }

        }

        #endregion



        #region Functions

        //Das ist die besagte Funktion die aufgerufen wird.

        internal void SetNewIcon(EntitySizeMode entitySizeMode, Icon ico, ExplorerEntityType exType) {

            if (ico != null) {

                if (this.ico != null) {

                    this.ico.Dispose();

                }

                this.entitySizeMode = entitySizeMode;

                this.type = exType;

                switch (entitySizeMode)

                {

                    case EntitySizeMode.Large:

                        this.sizeMode = ImageSizeEnum.Large;

                        break;

                    case EntitySizeMode.Normal:

                        this.sizeMode = ImageSizeEnum.Normal;

                        break;

                    case EntitySizeMode.Small:

                        this.sizeMode = ImageSizeEnum.Small;

                        break;

                }

                Size sz;

                if (exType == ExplorerEntityType.Folder)

                {

                    Icon tempIcon = Dev86UI.Properties.Resources.folder;

                    sz = this.sizeMode.GetSize();

                    this.ico = Utility.ImageUtil.ImageConverter.ResizeIcon(tempIcon, sz.Width, sz.Height);

                    tempIcon.Dispose();

                }

                else

                {


                    if (ico != null)

                    {

                        this.ico = ico;

                    }

                    else

                    {

                        this.ico = Dev86UI.Properties.Resources.FileIco;

                    }

                    sz = this.sizeMode.GetSize();

                    if (!Utility.Util.CompareSizes(sz, this.ico.Size))

                    {

                        Icon tempIco;

                        tempIco = (Icon)this.ico.Clone();

                        this.ico.Dispose();

                        this.ico = Utility.ImageUtil.ImageConverter.ResizeIcon(tempIco, sz.Width, sz.Height);

                        tempIco.Dispose();

                    }

                }

            }


        }


        #endregion

    }

}

Sieht jemand etwas auffälliges?

lg

Gateway

  • Autor

Es kommt keine Fehlermeldung.

Im Output Fenster steht lediglich folgendes:

Eine Ausnahme (erste Chance) des Typs "System.TypeLoadException" ist in Dev86UI.dll aufgetreten.

Einzelschritt: Nichtbenutzercode "System.Windows.Forms.Control.WmMouseUp" wird übersprungen.

Einzelschritt: Nichtbenutzercode "System.Windows.Forms.ButtonBase.WndProc" wird übersprungen.

Einzelschritt: Nichtbenutzercode "System.Windows.Forms.NativeWindow.DebuggableCallback" wird übersprungen.

Einzelschritt: Nichtbenutzercode "System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop" wird übersprungen.

Einzelschritt: Nichtbenutzercode "System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner" wird übersprungen.

Einzelschritt: Nichtbenutzercode "System.Windows.Forms.Application.ThreadContext.RunMessageLoop" wird übersprungen.

Einzelschritt: Nichtbenutzercode "System.Windows.Forms.Form.ShowDialog" wird übersprungen.

"GUITest.vshost.exe" (Verwaltet (v4.0.30319)): "C:\Windows\Microsoft.Net\assembly\GAC_MSIL\mscorlib.resources\v4.0_4.0.0.0_de_b77a5c561934e089\mscorlib.resources.dll" geladen

Einzelschritt: Nichtbenutzercode "System.Windows.Forms.Control.WmShowWindow" wird übersprungen.

Einzelschritt: Nichtbenutzercode "System.Windows.Forms.NativeWindow.DebuggableCallback" wird übersprungen.

Einzelschritt: Nichtbenutzercode "System.Windows.Forms.Control.SetVisibleCore" wird übersprungen.

lg

Gateway

Hm.. der Code scheint für mich zumindest erst einmal nicht auffällig zu sein. Der einzige Hinweis ist ja erst einmal die Dev86UI.dll und deutet meiner Meinung nach auf Zugriffe für x86 Systeme hin.

Gibt es evtl. auch Dev64UI.dll für Zugriffe auf x64 (falls du ein 64 Bit OS nutzt) und daher kommt es zu dem Fehler? Würde ich mir zumindest mal anschauen. Die DLL scheint zumindest keine Windows Komponente zu sein.

  • Autor

Die Klasse ExplorerEntity befindet sich innerhalb der Dev86UI.dll.

Und nein mit der Plattform hat es nichts zu tun und es gibt auch keine Dev64UI.dll (das 86 hat nichts mit der Plattform zu tun).

Ich habe in Erfahung gebracht das dieser Fehler häufig auftritt wenn Verweise auf Libraries gesetzt wurden, welche ein niedrigeres Zielframework besitzten.

Daraufhin habe ich alle Verweise der jeweiligen Projekte überprüft. Jedoch nutzten alle das Zielframework 4.0.

Sitze gerade ziemlich in der Sackgasse.

lg

Gateway

  • Autor

Hi,

ich bin zwischenzeitlich an mehr Informationen gekommen, die mich aber noch mehr verwirrten.

Der Exception Inhalt sieht wie folgt aus:

Methode nicht gefunden: "System.Drawing.Icon Utility.ImageUtil.ImageConverter.ResizeIcon(System.Drawing.Icon, Int32, Int32)".

Ich könnt hier echt gleich ausflippen :(. Zur Laufzeit sagt er mir die Funktion existiert nicht, aber warum wird mir dann die Funktion in der InteliSense Liste angezeigt?!

Und warum lässt er mich dann überhaupt compilieren?! :(

Das ist alles mehr als verwirrend.

lg

Gateway

EDIT:

Rätsel gelöst. Ich weiß nicht warum aber Visual Studio scheint die Utility Library nicht mehr beim starten des Debug Vorgangs ins lokale Verzeichnis zu kopieren. Warum das so ist weiß ich allerdings nicht.

Danke für deine Hilfe.

Bearbeitet von Gateway_man

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.