Troubleshooting Error: Loader Lock was detected

While working with Redemption library, we usually get the following error while debugging the project.

Attempting managed execution inside OS Loader lock. Do not attempt to run
managed code inside a DllMain or image initialization function since doing so
can cause the application to hang.

As per Dmitry Streblechenko (Redemption Team), this exception is raised when .NET thinks that a dll that it is loading is doing something that can potentially lock the loader (like circularly loading dlls etc). Redemption does load the MAPI libraries at the startup, but that is about it. That warning can be safely ignored.

 

Work-Around:

We can skip this error by clearing the LoaderLock checkbox in Debug -> Exceptions -> Managed Debud Assistants.

Debug | Exceptions | Managed Debug Assistants > LoaderLock (Uncheck this!)

Redemption Library is really wonderful creation. It helps the developers a lot in handling and accessing some attributes of Outlook Items which cannot be accessed using the API given by Microsoft.

Advertisements

Error: WriteFile failed => 0x5(5) when Makecert is run

Problem:

Makecert -sv MyCert.pvk -n”CN=MyCompanyCert” MyCert.cer -b01/01/2009 -e 12/31/2018

While executing the above command, sometimes we get the following error.

Error: WrtieFile failed => 0x5<5>

Solution:

The solution for this is to run the command prompt in admin mode.

This can be done by right-clicking on the cmd and selecting ‘Run as Administrator‘.

Hope this helps!

Troubleshooting Office 2007 Add-ins

Here are few links on troubleshooting Office 2007 and 2010 Add-ins which I just came across. I believe that one can get quick work-around to solve ( at least pin-down) the issue.

  • How to: Re-enable an Add-in That Has Been Disabled
  • Debugging in Application-Level Projects
  • Troubleshooting Run Time Errors in Office Solutions
  • Hope this helps!

    Troubleshooting Error – Unable to cast COM object {00063034-0000-0000-C000-000000000046}

    Have you ever suffered from the following error while working with COM objects?

    Unable to cast COM object of type ‘System.__ComObject’ to interface type ‘Microsoft.Office.Interop.Outlook.MailItem’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{00063034-0000-0000-C000-000000000046}’ failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

    I was a bit clueless why this is occurring even the code is perfect.

    Dim fname, email, cname As String
    Dim olContactItem As Outlook.ContactItem
    Dim ContactsFolder As Outlook.MAPIFolder = Globals.ThisAddIn.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)

    For i As Integer = 1 To ContactsFolder.Items.Count

    If TypeOf (ContactsFolder.Items(i)) Is Outlook.ContactItem Then

    olContactItem = ContactsFolder.Items(i)
    fname = olContactItem.FirstName
    email = olContactItem.Email1Address
    cname = olContactItem.CompanyName
    Marshal.ReleaseComObject(olContactItem)

    End If

    Next

    Later came to know about the fact that the objects are not released by Garbage Collector even if we call it and nullify the object using Nothing keyword. Here are some points that we need to take care while coding with COM objects like ContactItem, MailItem etc.

    • Declare all objects explicitly and release them each pass through the loop using Marshal.ReleaseComObject()
    • Try using a for() loop rather than a foreach() loop, the foreach() is not only slower but also creates hidden instance variables
    • Make sure no compound dot operators are being used. Instantiate an explicit object for each dot operator, that way you can release them explicitly

    Hope this helps!

    Prepare your Applications for Windows 7

    We all have this question in our mind.

    “Why does my application break when we change the Operating Systems?”

    Typically, whenever a new OS is released, Microsoft makes every effort to ensure application Compatibility. Unfortunately, as the OS evolves and when reliability, security and performance improvements are made, there are some comprises which are made that ends up breaking some applications. Thankfully, when the changes are decided to be made, there is some mitigation planned to address the applications which are broken. Hence, Application Compatibility is one important which is on the top of everybody’s mind.

    This series of posts covers information on how the core changes of Windows 7 will affect the applications. Also, it covers some basic methods to mitigate these issues from the viewpoint of Developers, IT Pros and End-users.

    A key consideration when moving to Windows 7 is whether your applications will run successfully. Download the Microsoft Application Compatibility Toolkit (ACT) to access the necessary tools and documentation to evaluate and mitigate application compatibility issues before deploying Windows 7.