문제

XP와 Vista에서 잘 실행되는 .NET 2.0 앱이 있지만 Windows 7 RC (X64)에서는 다음과 같은 오류가 발생합니다.

예외 정보


예외 유형 : System.outofMemoryException 메시지 : 메모리 밖. 데이터 : System.Collections.listDictionaryInternal TargetSite : void .ctor (System.Drawing.Image, System.Drawing2d.wrapMode) Helplink : NULL 소스 : System.Drawing

스택 트레이스 정보


at System.Drawing.textureBrush..CTOR (이미지 이미지, 랩 모드 랩 모드)에서 system.windows.forms.controlpaint.splagebackgroundimage (그래픽 G, 이미지 배경 이식, 색채 백색, ImagelAyout BackgroundImagelayout, 직사각형 경계, 사각형 클립 렉스, 오른쪽 틀림 피트 오른쪽 송로 피트 ) System.Windows.Forms.control.Paintbackground (System.Windows.Forms.control.paintbackground (PainteventArgs E, 사각형)의 System.windows.form.control. system.windows.forms.scrollablecontrol.onpaintbackground (painteventargs e)의 onpaintbackground (painteventargs pevent) system.windows.forms.control.paintwitherrorHandling (SaintVentargs E, Int16 Layer, Bolean disposeEventargs)의 System.Worm.conform.control. system.windows.forms.control.wndproc (message & m)의 system.windows.windows.forms.scrollablecontrol.wndproc (message & m)의 Message & M)

이런 일이 일어나고있는 이유에 대한 아이디어, 또는 그 주위에 어떻게 프로그램 할 수 있습니까? 그것은 단지 특별한 배경이없는 표준 winform을 그리는 것입니다.

업데이트 : 이것은 BackgroundImagelayout = imagelayout.tile이 기본값 인 경우에만 문제가된다는 것을 알았습니다. 줌 또는 중앙으로 설정하면 문제가 해소됩니다. 그래도 타일이 필요하기 때문에 꽤 불만족 스럽습니다.

도움이 되었습니까?

해결책 2

이에 대한 솔루션은 배경에 사용되는 PNG 파일 자체와 관련이 있습니다. 방금 Paint.net으로 열어 다시 개설 한 다음 프로젝트에 다시 넣고 작동했습니다.

무엇이 바뀌 었는지 확실하지 않지만 문제가 해결되었습니다.

다른 팁

나는 비슷한 문제가 있었다. 내 경우에는 내 메모리 스트림을 처분 한 후 이미지를로드했습니다.

//The following throws and OutOfMemoryException at the TextureBrush.ctor():

    /*someBytes and g declared somewhere up here*/
    Bitmap myBmp = null;
    using(MemoryStream ms = new MemoryStream(someBytes))
       myBmp = new Bitmap(ms);

    if(myBmp != null) //that's right it's not null.
       using(TextureBrush tb = new TextureBrush(myBmp)) //OutOfMemoryException thrown
          g.FillRectangle(tb,0,0,50,50);

//This code does not throw the same error:

    /*someBytes and g declared somewhere up here*/
        MemoryStream ms = new MemoryStream(someBytes);
        Bitmap myBmp = new Bitmap(ms);

        if(myBmp != null)
           using(TextureBrush tb = new TextureBrush(myBmp))
              g.FillRectangle(tb,0,0,50,50);

TextureBrush 클래스를 호출하여 타일링을 위해 이미지를 처분하거나 이미지가있는 곳에서 Filestream 객체를 닫지 마십시오. 그렇지 않으면 TextureBrush 클래스는 메모리 예외를 제외합니다.

따라서 더 좋은 방법은 TextureBrush 이미지를 호출하여 타일 이미지를 표시 한 다음 Windows 형태의 페인트 이벤트에서 Filestream 객체를 닫는 것입니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top