2009-04-30 22 views
5

मुझे लगता है कि XP ​​और Vista पर ठीक चलाता है एक .NET 2.0 अनुप्रयोग है, लेकिन विंडोज 7 आर सी (64) पर यह निम्न त्रुटि के साथ दुर्घटनाओं:विंडोज 7 TextureBrush..ctor() त्रुटि

अपवाद सूचना


अपवाद प्रकार: System.OutOfMemoryException संदेश: स्मृति से बाहर। डाटा: System.Collections.ListDictionaryInternal TargetSite: शून्य .ctor (System.Drawing.Image, System.Drawing.Drawing2D.WrapMode) HELPLINK: शून्य स्रोत: System.Drawing

StackTrace सूचना


System.Drawing.TextureBrush..ctor (छवि छवि, wrapMode wrapMode) System.Windows.Forms.ControlPaint.DrawBackgroundImage पर (ग्राफिक्स जी, छवि backgroundImage, रंग बैककलर, ImageLayout backgroundImageLayout, आयत सीमा, आयत clipRect, प्वाइंट scrollOffset पर , राइट टॉफ्ट दाएं टोफ्ट)System.Windows.Forms.Control.PaintBackground (PaintEventArgs e, आयताकार आयताकार, रंगीन बैक रंग, प्वाइंट स्क्रॉलऑफसेट) System.Windows.Forms.Control.PaintBackground (PaintEventArgs e, आयताकार आयताकार) System.Windows.Forms पर। Control.OnPaintBackground (PaintEventArgs pevent) System.Windows.Forms.ScrollableControl.OnPaintBackground (PaintEventArgs ई) System.Windows.Forms.Control.PaintWithErrorHandling पर (PaintEventArgs ई, int16 परत, बूलियन disposeEventArgs) पर System.Windows.Forms पर .Control.WmPaint (संदेश & मी) System.Windows.Forms.Control.WndProc (संदेश & मी) पर System.Windows.Forms.ScrollableControl.WndProc पर (संदेश & मी)

यह क्यों हो रहा है के बारे में कोई विचार, या मैं इसके आसपास प्रोग्राम कैसे कर सकता हूं? यह सिर्फ एक विशेष पृष्ठभूमि के साथ एक मानक Winform पेंटिंग है।

अद्यतन: मुझे पता चला है कि यह केवल एक मुद्दा है जब BackgroundImageLayout = ImageLayout.Tile, जो डिफ़ॉल्ट भी है। इसे ज़ूम या सेंटर पर सेट करें, और समस्या गायब हो जाती है। यद्यपि यह असंतोषजनक है, क्योंकि मुझे इसे टाइल करने की आवश्यकता है।

+0

क्या यह XP और Vista ** 64-bit ** पर ठीक काम करता है? –

+0

हां, यह XP और Vista दोनों 32 और 64 बिट संस्करणों पर ठीक काम करता है। –

+0

धन्यवाद (यह अंधेरे में एक शॉट था, हाल ही में क्रॉस-आर्क मुद्दों से संबंधित कुछ समान ध्वनि समस्या थी।) क्षमा करें, विचारों से बाहर। –

उत्तर

1

उस समाधान को हल करता है जो पीएनजी फ़ाइल के साथ ही पृष्ठभूमि के लिए उपयोग किया जाता था। मैंने इसे अभी पेंट.नेट के साथ खोला और इसे बचाया, फिर इसे परियोजना में वापस रख दिया और यह काम किया।

सुनिश्चित नहीं है कि क्या बदल गया, लेकिन इसने समस्या को हल किया।

+0

इसने मेरी समस्या का समाधान किया .. thnx –

3

मुझे एक ही समस्या थी। मेरे मामले में मैंने अपनी मेमोरीस्ट्रीम का निपटारा किया था, मैंने छवि को लोड किया था।

//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); 
+0

यह वास्तव में मेरी समस्या थी। क्या कोई ऐसा व्यक्ति जो "हुड के नीचे" समझता है, इस व्यवहार को समझाने के लिए परेशान होगा? – Dinei

1

कृपया छवि निपटाने या खपरैल के लिए TextureBrush वर्ग कॉल करने से पहले जहां छवि मिल गया है से filestream वस्तु बंद नहीं करते। अन्यथा TextureBrush क्लास आउट ऑफ़ मेमोरी अपवाद फेंक देगा।

तो बेहतर तरीका है TextureBrush छवि को कॉल करके टाइल छवि को दिखाने और फिर विंडोज़ फॉर्म की पेंट घटना में फ़ाइलस्ट्रीम ऑब्जेक्ट को बंद करना।