ObjectNotFoundException while removing Portlet from display

Hi,
My requirement on Personalization is to display all Portlets(names) with Checkboxes, user can decide which portlets to be displayed/not.
I'm using streaming mode.
I have 2 methods to do this: getPageView and removePlaceableInstances.
I'm getting the following exception:
<pre>com.bea.netuix.application.exception.ObjectNotFoundException: [Primary desktop] with id [Webapp: [myGearbox] PortalPath:
[personalization] DesktopPath: [personalize.jsp]] could not be found in the database.
at com.bea.netuix.application.manager.persistence.jdbc.DesktopInstanceDelegate.createDesktopInstance(Ljava.sql.C
onnection;Lcom.bea.netuix.application.identifier.DesktopDefinitionId;Ljava.lang.String;)Lcom.bea.netuix.application.inst
ance.internal.DesktopInstanceInternal;(DesktopInstanceDelegate.java:458)
at com.bea.netuix.application.manager.persistence.jdbc.DesktopInstanceDelegate.getCreateDesktopInstance(Ljava.sq
l.Connection;Lcom.bea.netuix.application.identifier.DesktopDefinitionId;Ljava.lang.String;)Lcom.bea.netuix.application.i
dentifier.DesktopInstanceId;(DesktopInstanceDelegate.java:1012)</pre>
I have attached the code here with for reference.
<pre>public class PersonalizationUtil
public static PageView getPageView( String pageInstanceId, String webAppName, String portalPath,
String desktopPath, Locale locale, HttpServletRequest request ) {
PortalCustomizationManager cmgr = PortalBeanManager.getPortalCustomizationManager();
PageDefinitionManager pmgr = PortalBeanManager.getPageDefinitionManager();
try
return PortalManager.getPageView( pageInstanceId, webAppName, portalPath, desktopPath, true, locale, request );
catch( Exception e )
System.out.println( "PortalVisitorManager - " + e );
return null;
public static void removePlaceableInstances( String placeableId, String webapp, String portalPath,
String desktopPath, HttpServletRequest request )
placeableId = "portletCompanyStore_1";
try {
PortalCustomizationManager cmgr = PortalBeanManager.getPortalCustomizationManager();
PageDefinitionManager pmgr = PortalBeanManager.getPageDefinitionManager();
//AppContext ac = AppContext.getAppContext(request);
CustomizationContext customizationContext = new CustomizationContext(request);
customizationContext.setVisitorMode(true);
DesktopView desktopView = cmgr.getDesktopView(customizationContext, webapp, new PortalPath(portalPath), new DesktopPath(desktopPath));
System.out.println("desktopview - " + desktopView);
DesktopDefinitionId ddId = new DesktopDefinitionId( webapp, new PortalPath( portalPath ), new DesktopPath( desktopPath ) );
//customizationContext.setUserDesktopInstanceId(
InitialContext ic = new InitialContext();
PageDefinitionManagerHome home = (PageDefinitionManagerHome) PortableRemoteObject.narrow(ic.lookup("java:comp/env/ejb/PageDefinitionManager"), PageDefinitionManagerHome.class);
PageDefinitionManager mgr = home.create();
PageDefinition homePageDefinition = mgr.getPageDefinition(customizationContext,
"home",
webapp);
PageView homePageView = mgr.getPageView(customizationContext,homePageDefinition.getPageDefinitionId());
PageView usersHomePageView = PersonalizationUtil.getPageView(homePageView.getPageDefinitionId().toString(),webapp,portalPath,desktopPath,request.getLocale(),request);
PlaceableInstance placeableInstance = usersHomePageView.getPortletView(placeableId).getPlaceableInstance();
System.out.println("NNINFO: PlaceableInstance - " + placeableInstance);
//PageView usersHomePageView = (PageView) request.getAttribute("usersHomePageView");
if ( usersHomePageView != null ) {
//PlaceableInstance placeableInstance = usersHomePageView.getPortletView("portletCompanyStore_1").getPlaceableInstance();
cmgr.removePlaceable( customizationContext, new DesktopDefinitionId( webapp, new PortalPath( portalPath ), new DesktopPath( desktopPath ) ), placeableInstance );
} else {
System.out.println("nulll");
} catch (Exception e) {
e.printStackTrace();
}</pre>
Am i doing anything wrong??
Any help or hint would be greatly appreciated!!
Thanks,
-Nach.

Chris, Thank you very much for your valueable inputs.
Now i have changed the code as per your inputs.
I'm currently getting PortalCustomizationManager as follows:
PortalCustomizationManager cmgr = PortalBeanManager.getPortalCustomizationManager();
1) Is this the right way?
CustomizationContext customizationContext = new CustomizationContext(Locale.US,request);
customizationContext.setVisitorMode(true);
DesktopView desktopView = cmgr.getDesktopView(customizationContext, webapp, new PortalPath(portalPath), new DesktopPath(desktopPath));
System.out.println("desktopview - " + desktopView);
But desktopView is null.......
2) What could be the possible reason?
Also in the JSP,
AppContext ac = AppContext.getAppContext(request);
if (!ac.isDotPortal()) {
String currentWebAppName = ac.getWebAppName();
String currentDesktopPath = ac.getDesktopPath();
String currentPortalPath = ac.getPortalPath();
currentDesktopPath and currentPortalPath are null....
Hence i'm getting the desktopPath and portalPath as follows:
String pathInfo = request.getPathInfo();
String portalPath = pathInfo.substring(1, pathInfo.lastIndexOf("/"));
String desktopPath = pathInfo.substring(pathInfo.lastIndexOf("/") + 1, pathInfo.length());
3) What is the right approach to get portalPath and desktopPath. If i should get the desktopPath and portalPath from AppContext, then what could be the possible reasons for getting null.
Again, your inputs are more valueable and crucial to me now.
Thanks
-Nach.

Similar Messages

  • Facing problem with the code for sending an .xls attachment via email, a field value contains leading zeros but excel automatically removes these from display i.e. (00444 with be displayed as 444).kindly guide .

    Facing problem with the code for sending an .xls attachment via email, a field value contains leading zeros but excel automatically removes these from display i.e. (00444 with be displayed as 444).kindly guide .

    Hi Chhayank,
    the problem is not the exported xls. If you have a look inside with Notepad or something like that, you will see that your leading zeros are exported correct.Excel-settings occurs this problem, it is all about how to open the document. If you use the import-assistant you will have no problems because there are options available how to handle the different columns.
    Another solution might be to get familiar with ABAP2XLS-Project. I got in my mind, that there is a method implemented, that will help you solving this problem. But that is not a five minute job
    ~Florian

  • MSS - How to remove retirees from displaying in MSS

    Hello,
    Does anyone know the best approach to exclude retirees (PA000.STAT2 = 2) from displaying in MSS?  We currently keep retirees in the org unit they retired from using creating a clone of their current position number to a new position number that starts with 991 or 993.  Terminated employees are put in position 99999999 and since there is OM relationships, those do not show up.
    Thank you,
    Keith Pieritz

    ya you can   make the settings in view T77S0 for only active employees keep as 3 u can achive it
    go to sm30 v_t77s0 create new entries enter values as :-
    a) Access the V_T77S0 view.
    b) Choose New Entries.
    c) In the Group field (group name), enter ESS.
    d) In the Sem. Abbr. field (semantic abbreviation) enter STAT2 .
    e) In the Value Abbr. field (value of semantic abbreviation), restrict the number of employees covered by the search by entering the relevant employment status for the search.
    save it  ....and once chk in portal after reloggin in

  • Exception while removing policy from protected .docx file.

    I am getting exception as below for java client code snippet while inspecting document which is secured using MS Word 2007.
    Properties connectionProps = new Properties();
    connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT _EJB_ENDPOINT, "jnp://vvcon-qa-1.ptcnet.ptc.com:1099");
    connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPO RT_PROTOCOL,ServiceClientFactoryProperties.DSC_EJB_PROTOCOL);        
    connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_ TYPE, "JBoss");
    connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENT IAL_USERNAME, "administrator");
    connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENT IAL_PASSWORD, "administrator");
    ServiceClientFactory factory = ServiceClientFactory.createInstance(connectionProps);
    RightsManagementClient rightsClient = new RightsManagementClient(factory);
    //Reference a policy-protected Word document from which to remove a policy
    FileInputStream is = new FileInputStream(args[0]);
    Document inPDF = new Document(is);
    //Create a Document Manager object
    DocumentManager  documentManager = rightsClient.getDocumentManager();
    RMInspectResult lic = documentManager.inspectDocument(inPDF);
    Exception I am getting
    com.adobe.edc.sdk.SDKException: Error while looking up RM Header in the document -- Invalid argument(error code bin: 1281, hex: 0x501)
        at com.adobe.livecycle.rightsmanagement.RightsManagementService.throwSDK Exception(RightsManagementService.java:958)
        at com.adobe.livecycle.rightsmanagement.RightsManagementService.getLicen seID(RightsManagementService.java:794)
        at com.adobe.livecycle.rightsmanagement.RightsManagementService.inspectD ocument(RightsManagementService.java:2260)
    Event if I try with user who can access document after connecting to LiveCycle ES2 from Microsoft Word 2007 I am getting same exception.
    I can acess document from MS Word after I have secured it using all users who have right permission for document but from java client I am not able to do that. Looks like RMS information is not embedded properly in my document.
    jars included in my classpath are
    adobe-rightsmanagement-client.jar,namespace.jar,jaxb-api.jar,jaxb-impl .jar,jaxb-libs.jar,jaxb-xjc.jar,relaxngDatatype.jar,adobe-livecycle-cl ient.jar,adobe-usermanager-client.jar,jbossall-client.jar
    My client is running on Windows XP 32 bit with Office 2007.
    Server is installed on Windows server 2008 R2 64 bit and deplyoed using JBoss.
    One more intresting fact here is my java client can protect document and unprotect same document.
    However document which is protected by Microsoft Rights Management extension plugin cannot
    be unprotected by my java client.
    Regards,
    Sharang

    It seems to work properly, in that, the appropriate words are removed from the story. However, I'd like to keep the story in order, as it was before any manipulation took place (just with the words removed). Currently, I am presented with a column of words with the order of words seemingly random.
    Thanks.

  • Remove decimal from displaying in prices?

    I would like to remove the decimal from my product price so it will be displayed Kr.390  or my first choice if anyone knows how to solve it is Kr. 390,-
    Costs are now presented Kr.290,00 that is not correctly.
    Hope someone has a solution to this ...

    Here's a link that contains a simple code snippet that will do this for you - http://www.twoblokeswithapostie.com/blog/2013/05/27/eliminating-decimals-product-prices-bu siness-catalyst/
    You may have to replace . with , in price = price.split("."); if your prices have a comma in them instead of a dot.
    Cheers,
    Mario

  • Query timedout expired error while removing PRIV from a Role in IDM

    I am trying to remove a PRIV from a role and i am getting Query timeour error.
    I tried removing this PRIV from workflow and there it takes some time to process and then i get a promt of error which is staying for a sec and then i get to home page.
    I also tried removing this PRIV from Identity center and there I get error window like this:
    Method: Save Identity Store Privilege
    Source: Microsoft SQL Native Client
    Error: 80040E31h (-2147217871)
    Description: Query timedout expired.
    this is the error i am getting when i try.
    This is very critical role assigned to many users.
    Please check this and let me know if you need any more information to understand and give a solution.
    FYI: I am on SAP Netwearver 7.0 version.
    This role is assigned to almost 1150 users in the system.
    Since, I dint see anyone giving answer for this, may be this helps to analyse the solution for this.
    Edited by: ARUN KUMAR AKUTHOTA on Apr 28, 2010 3:33 PM

    Dear Sabita,
    Any update if this has been fixed in SP13 or SP14. We are planning to upgrade to SP13.
    We are unable to do even provisioning in multiple systems. Only in 1 system role is getting provisioned and other system its not happening. Same situation for removal of roles also.
    Also, we have not upgraded the ABAP patches in A2D system to synch with GRC SP9, whereas in R1D the patches are in synch with GRC SP9. But the issue is happening with R1D system (patches are in Synch) and not in A2D system.
    Thanks and Best Regards,
    Srihari.K

  • UnsupportedOperationException Error while removing object from List

    Hi,
    I need to remove a set of objects from List if it contains similar objects as the other one.
    Follwing is the code snippet of the above scenario...
    List selectedPaxList = new ArrayList();
    TreeSet seatAssignedPaxlist= new TreeSet();
    selectedPaxList.add("1");
    selectedPaxList.add("2");
    selectedPaxList.add("3");
    seatAssignedPaxlist.add("1");
    seatAssignedPaxlist.add("2");
    if(selectedPaxList.containsAll(seatAssignedPaxlist))
    selectedPaxList.removeAll(seatAssignedPaxlist);
    If i do this in java program it executes fine without any error.But if I do the same in JSP I am getting the following error......
    java.lang.UnsupportedOperationException
    at java.util.AbstractList.remove(AbstractList.java:167)
    at java.util.AbstractList$Itr.remove(AbstractList.java:432)
    at java.util.AbstractCollection.removeAll(AbstractCollection.java:351)
    Plz... help me to resolve the issue

    java.lang.UnsupportedOperationException
    at
    java.util.AbstractList.remove(AbstractList.java:167)
    at
    java.util.AbstractList$Itr.remove(AbstractList.java:43
    2)
    at
    java.util.AbstractCollection.removeAll(AbstractCollect
    ion.java:351)
    That stack trace looks wrong to me.
    ArrayList overrides the remove method, so it
    shouldn't be using the method in AbstractList. That's what I thought, too. There is either something missing or it's not an ArrayList. In fact the javadoc of AbstractList.remove sais:
    "This implementation always throws an UnsupportedOperationException."
    So it really looks like another subclass is used.
    Also
    the object it is trying to remove is a list (from
    your exmaple it should be a String)
    I could be wrong.These are just the code references not the parameters, I think.
    -Puce

  • Customizing Audit Log Report - Adding/Removing Columns from Display

    Hi All -
    Has anyone tried adding/removing the columns from Out of Box Auditi Log report with minor customizations to the code/configuration files ? Right now , when the Audit Log report is executed, there are numbe of columns that appear on report (Server, Client IP etc) which are too technical for the client and requirement is remove some of these and add some more for the attributes that we are audit logging through Audit workflow service. If you have done something similar in the past, please provide me with some inputs. Any sample code, examples will be highly appreciated.

    Hello Gurus,
    I also have same kind of requirement.WE have to send a monthly report to customer where number of users created and deleted to be given to them.
    Its urgent.Please help
    Thanks in advance

  • Removing Components from display

    Hi,
    I have a JPanel with a number of JLabels inside.
    All visible on the screen.
    I want to remove all the JLabels (permanently), so I call:
    jPanel.removeAll();   
    jPanel.validate();Yet the JLabels do not disappear from the screen.
    Any ideas on this appreciated.
    Ta.

    jPanel.removeAll();
    jPanel.invalidate();
    jPanel.validate();
    jPanel.repaint();Thanks. That does the trick. I didn't realize it was necessary to use both validate and repaint.

  • Deadlock while removing PhantomReference from ReferenceQueue

    Why does the following cause a deadlock? Tested under 1.5 and 1.6. Why garbage collector doesn't (eventually) enqueue the reference? Anyhow, the reference queue doesn't seem to have a clue, and waits indefinitely...
    import java.lang.ref.PhantomReference;
    import java.lang.ref.Reference;
    import java.lang.ref.ReferenceQueue;
    public class NewMain {
        public static void main(String[] args) throws Exception {
            Object o = new Object();
            ReferenceQueue q = new ReferenceQueue();
            PhantomReference ref = new PhantomReference(o, q);
            o = null;
    //        System.gc(); // <-- if this is commented ...
            ref = (PhantomReference)q.remove(); // ... then this creates a deadlock!
            System.out.println("done");
    }Instead of System.gc(), I can achieve a similar effect using something like:
    for (int i = 0; i < 100000000; i++) new Object().toString();Any ideas?
    Message was edited by:
    ounos

    Your original NewMain compiles to the following bytecode:    0:   new     #2; //class java/lang/Object
       3:   dup
       4:   invokespecial   #1; //Method java/lang/Object."<init>":()V
       7:   astore_1
       8:   new     #3; //class java/lang/ref/ReferenceQueue
       11:  dup
       12:  invokespecial   #4; //Method java/lang/ref/ReferenceQueue."<init>":()V
       15:  astore_2
       16:  new     #5; //class java/lang/ref/PhantomReference
       19:  dup
       20:  aload_1
       21:  aload_2
       22:  invokespecial   #6; //Method java/lang/ref/PhantomReference."<init>":(Lj
    ava/lang/Object;Ljava/lang/ref/ReferenceQueue;)V
       25:  astore_3
       26:  aconst_null
       27:  astore_1
       28:  aload_2
       29:  invokevirtual   #7; //Method java/lang/ref/ReferenceQueue.remove:()Ljava
    /lang/ref/Reference;
       32:  checkcast       #5; //class java/lang/ref/PhantomReference
       35:  astore_3
       36:  getstatic       #8; //Field java/lang/System.out:Ljava/io/PrintStream;
       39:  ldc     #9; //String done
       41:  invokevirtual   #10; //Method java/io/PrintStream.println:(Ljava/lang/St
    ring;)V
       44:  returnHowever, I don't believe that the VM spec would prohibit JITs from optimising away instructions 26 and 27. As a general rule, if you're playing with reference types you should probably assume that a reference to an object could still be on the stack until the method in which it was created returns or throws an exception up the stack.

  • Removing wildcard(%) from display

    Whenever we create a condition on a character or varchar item(field) discoverer by default adds the message 'use % for wildcard' along with the custom prompt. How do I remove this message? We have few reports which return huge amounts of data. so we want to hide the option of wildcard character from user.
    Thanks

    Hi
    Now I understand and see where you are going with this. You are saying that it would be perfectly ok for a user to use % in one of the conditions, just not in all of the conditions.
    We can use a new condition to check this and prevent the query from running although we cannot give the user a nice message. All we can do is stop the query from running and return no data.
    Create this calculation called Test_Values:
    CASE WHEN :Param1 = '%' AND :Param1 = :Param2 THEN 0 ELSE 1 END
    Create a new condition:
    1 = Test_Values
    Now if the user keys % into all parameters the calculation called Test_Values will return 0 and hence 1 = Test_Values will return false which will cause the query not to execute.
    Hope this helps
    Regards
    Michael

  • Removing scratches from display screen

    I know they advertised this stuff on TV that magically fills in the scratches on your glasses...do you think it will work on the screen? Do you have a better product to remove them?

    I find it hilarious when persons such as yourself just make things up in complete oblivion. The warranty does N-O-T cover scratches. And... How did he get scratches on his screen, you ask? Because the material that covers the front of the iPod checks in at about a 1 on the hardness scale.
    To the OP... I suggest you Google...
    Ice Cream
    Apple Sauce
    iKlear
    Brasso
    All four should work fine.
    After removing the scratches, I highly suggest you purchase a screen cover...
    The Invisible Shield is known to do wonders.
    Good luck.

  • Every time I open a new Tab the Yahoo Web Search page appears. How do I remove Yahoo from displaying content on each Tab I open?

    I am able to select the website I wish to appear as my Home Page when I open my Firefox browser. However, each time I open a New Tab it opens up to a page showing the YAHOO Web Search Bar. Each and every subsequent Tab opens up showing the Yahoo information. Please Help me DELETE YAHOO ...

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode
    *https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes

  • Unable to remove delegates from calendar:

    While removing delegates from calendar error is generated "The Delegates settings were not saved correctly.  Cannot activate send-on-behalf-of list.You do not have sufficient permission to perform this operation on this object."
    I Referred  and re-added AD permissions & also made desired registry settings as per below solutions in links but no luck! Please suggest.
    http://support.microsoft.com/kb/2593557
     http://community.spiceworks.com/how_to/show/41829-getting-error-after-adding-new-delegates-the-delegates-settings-were-not-saved-correctly-cannot-activate-send-on-behalf-of-list-you-do-not-have-sufficient-privileges-to-perform-this-operation-on-this-object
    Aditya Mediratta

    I found a fix for this. The mentioned user that was added as delegate
    missed send on behalf of permission on mailbox, Re-adding permissions and then removing this from delegate
    got this fixed. Thanks All!
    Aditya Mediratta

  • Can't delete a file displayed in ListView ("File in use") even after removing it from window.

    I have a ListView displaying a collection of icons. The user can then select different icons (checkboxes) to do things like Copy or Delete.
    Problem is, when I try to delete the actual file from the disk, I get an error telling me the file is "in use" ("vshost.exe", the VS runtime during testing).
    I thought maybe it was because it still appeared in the window and was still in the ImageList, but even after removing it from both locations, I still get the error. My code:
    Dim intCnt As Integer = 0
    Do
    ImageList2.Images.RemoveAt(intIconsChecked(intCnt)) ' Remove from collection.
    lsvCollection.Items.RemoveAt(intIconsChecked(intCnt)) ' Remove from ListView window.
    FileIO.FileSystem.DeleteFile(strIconPath & "\Icon" & Format(intCnt + 1, "00") & ".rsc") ' "+1" b/c Icons start with "01".
    FileIO.FileSystem.DeleteFile(strIconPath & "\Icon" & Format(intCnt + 1, "00") & ".png") ' "In use" Error here.
    ".rsc" deletes just fine, so I know I'm deleting the correct file. Why does VS still think the file is still "in use"?
    Thx

    Mugsy,
    Consider this as food for thought, even if you don't use it.
    If you set it up right then you can control how it works. A reference is a reference and any left behind will cause you grief down the road when you try to delete things.
    As an example, a simple class follows. It does *not* implement IDispose, although it does have a private shared Dispose method in it:
    Public Class MyImages
    Private _bmp As Bitmap
    Private _name As String
    Private _sourceFilePath As String
    Private Sub New(ByVal bmp As Bitmap, _
    ByVal name As String, _
    ByVal filePath As String)
    _bmp = bmp
    _sourceFilePath = filePath.Trim
    _name = name.Trim
    End Sub
    Public ReadOnly Property Bmp As Bitmap
    Get
    Return _bmp
    End Get
    End Property
    Public ReadOnly Property Name As String
    Get
    Return _name
    End Get
    End Property
    Public ReadOnly Property SourceFilePath As String
    Get
    Return _sourceFilePath
    End Get
    End Property
    Public Shared Sub AddNew(ByRef miList As List(Of MyImages), _
    ByVal imageFilePath As String)
    Try
    If miList Is Nothing Then
    Throw New ArgumentNullException("The collection of MyImages cannot be null.")
    ElseIf String.IsNullOrEmpty(imageFilePath) OrElse imageFilePath.Trim = "" Then
    Throw New ArgumentException("The file path of the image cannot be null or empty.")
    ElseIf Not My.Computer.FileSystem.FileExists(imageFilePath) Then
    Throw New IO.FileNotFoundException("The file path of the image could not be located.")
    Else
    ' Should do validation here that the file
    ' is actually an image but I'll not do this
    ' here...
    Dim thisBMP As Bitmap = New Bitmap(imageFilePath)
    miList.Add(New MyImages(thisBMP, GetFileNameWithoutExtension(imageFilePath), imageFilePath))
    End If
    Catch ex As Exception
    Throw
    End Try
    End Sub
    Public Shared Sub AddNew(ByRef miList As List(Of MyImages), _
    ByVal imageFilePath As String, _
    ByVal imageName As String)
    Try
    If miList Is Nothing Then
    Throw New ArgumentNullException("The collection of MyImages cannot be null.")
    ElseIf String.IsNullOrEmpty(imageFilePath) OrElse imageFilePath.Trim = "" Then
    Throw New ArgumentException("The file path of the image cannot be null or empty.")
    ElseIf Not My.Computer.FileSystem.FileExists(imageFilePath) Then
    Throw New IO.FileNotFoundException("The file path of the image could not be located.")
    ElseIf String.IsNullOrEmpty(imageName) OrElse imageName.Trim = "" Then
    Throw New ArgumentException("The name of this image cannot be null or empty.")
    Else
    ' Should do validation here that the file
    ' is actually an image but I'll not do this
    ' here...
    Dim thisBMP As Bitmap = New Bitmap(imageFilePath)
    miList.Add(New MyImages(thisBMP, imageName, imageFilePath))
    End If
    Catch ex As Exception
    Throw
    End Try
    End Sub
    Public Shared Sub Remove(ByRef miList As List(Of MyImages), _
    ByVal imageFilePath As String, _
    Optional ByVal removeFilePathAlso As Boolean = False)
    Try
    If miList Is Nothing Then
    Throw New ArgumentNullException("The collection of MyImages cannot be null.")
    ElseIf String.IsNullOrEmpty(imageFilePath) OrElse imageFilePath.Trim = "" Then
    Throw New ArgumentException("The file path of the image cannot be null or empty.")
    ElseIf Not My.Computer.FileSystem.FileExists(imageFilePath) Then
    Throw New IO.FileNotFoundException("The file path of the image could not be located.")
    Else
    Dim findInstance As System.Collections.Generic.IEnumerable(Of MyImages) = _
    From mi As MyImages In miList _
    Where mi.SourceFilePath = imageFilePath
    If findInstance.Count <> 1 Then
    Throw New ArgumentException("The instance of MyImages specified by the" & vbCrLf & _
    "image file path is not in the collection.")
    Else
    Dispose(findInstance.First)
    If removeFilePathAlso Then
    My.Computer.FileSystem.DeleteFile(findInstance.First.SourceFilePath)
    End If
    miList.Remove(findInstance.First)
    End If
    End If
    Catch ex As Exception
    Throw
    End Try
    End Sub
    Private Shared Sub Dispose(ByVal instance As MyImages)
    If instance IsNot Nothing AndAlso instance._bmp IsNot Nothing Then
    instance._bmp.Dispose()
    instance._bmp = Nothing
    End If
    End Sub
    End Class
    When you look through that, look specifically at the "Remove" method and in particular, look at the order in which things are done. That's the critical part in this.
    I tested it with a simple form:
    Two buttons, a checkbox, and a picturebox. I also copied a small folder full of image files to my desktop since I'll be deleting a file from it. Following is the code for Form1:
    Option Strict On
    Option Explicit On
    Option Infer Off
    Imports System.IO.Path
    Public Class Form1
    Private miList As New List(Of MyImages)
    Private Sub Form1_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) _
    Handles MyBase.Load
    Dim desktop As String = _
    My.Computer.FileSystem.SpecialDirectories.Desktop
    Dim imgFolder As String = _
    Combine(desktop, "Images")
    PictureBox1.BorderStyle = BorderStyle.FixedSingle
    For Each imgFilePath As String In My.Computer.FileSystem.GetFiles(imgFolder)
    MyImages.AddNew(miList, imgFilePath)
    Next
    btn_RemoveFirstImage.Enabled = False
    CheckBox_RemoveSourcePath.Enabled = False
    End Sub
    Private Sub btn_ShowFirstImage_Click(sender As System.Object, _
    e As System.EventArgs) _
    Handles btn_ShowFirstImage.Click
    Try
    If miList.Count >= 1 Then
    With PictureBox1
    .SizeMode = PictureBoxSizeMode.Zoom
    .Image = miList(0).Bmp
    End With
    btn_RemoveFirstImage.Enabled = True
    CheckBox_RemoveSourcePath.Enabled = True
    End If
    Catch ex As Exception
    MessageBox.Show(String.Format("An exception was thrown:{0}{0}{1}", vbCrLf, ex.Message), _
    "Exception", MessageBoxButtons.OK, MessageBoxIcon.Warning)
    End Try
    End Sub
    Private Sub btn_RemoveFirstImage_Click(sender As System.Object, _
    e As System.EventArgs) _
    Handles btn_RemoveFirstImage.Click
    Try
    If miList.Count >= 1 Then
    MyImages.Remove(miList, miList(0).SourceFilePath, CheckBox_RemoveSourcePath.Checked)
    End If
    PictureBox1.Image = Nothing
    btn_RemoveFirstImage.Enabled = True
    CheckBox_RemoveSourcePath.Enabled = True
    Catch ex As Exception
    MessageBox.Show(String.Format("An exception was thrown:{0}{0}{1}", vbCrLf, ex.Message), _
    "Exception", MessageBoxButtons.OK, MessageBoxIcon.Warning)
    End Try
    End Sub
    End Class
    Running it is straightforward:
    Now when I click to show the first one:
    A different image is shown because that first one no longer exists - either in the collection or in the folder.
    Closing/disposing all references is the key and the order matters.
    Something to consider the next time around. :)
    Still lost in code, just at a little higher level.

Maybe you are looking for

  • Dump in a Select query

    Hi All, I am getting a dump & the dump says " TIME LIMIT EXCEEDED". The code as  below:- LOOP AT it_gen1 INTO wa_gen1.         SELECT  vbelv posnv           FROM  vbfa     INTO TABLE  li_vbfa          WHERE  vbeln = wa_gen1-bil_number            AND 

  • IBooks Author: superscript not displaying after export to iPad / iPhone

    superscript displays perfectly in iBooks Author on my Mac but reverts to normal baseline in iBooks on iOS. I have tried with different font - same problem. What could the problem be?

  • How to display the loading wheel?

    Hi, I have my own component and want to display the loading wheel while the view is being generated. Is there an easy way how I can achieve this? Thanks for help!!

  • HD - Premiere Pro 2.0

    Hi I'm about to start a TV project that needs to be HD Pal...  I've got Premiere Pro 2.0 - does it handle HD?  I don't do much editing - so don't want to upgrade unless necessary... I've not worked in HD before - please can someone advise me on resol

  • TS1538 Iphone 5 crashes laptop and netbook when attempting to connect to itunes.

    Iphone 5 crashes laptop running win 7 enterprise and netbook running win xp pro when connected via usb, isn't recognized in itunes or on pc device manager connected to desktop. It will charge using original cable and mains charger. Any ideas? been at