Thursday, May 22, 2008

ASPENCRYPT - Object Already Exists

If you get this error re-install Aspencrypt.

Object already exists.

Server Error in '/' Application.

Object already exists.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Object already exists.


Source Error:

Line 66:     Public Shared Function Encrypt(ByVal UserID As String) As String Line 67:         Dim CM As New CryptoManagerClass Line 68:         Dim Context As ICryptoContext = CM.OpenContext("mycontainer", True) Line 69:         Dim key As ICryptoKey = Context.GenerateKeyFromPassword("elphantswanderingacr0ssapl14n", ASPENCRYPTLib.CryptoAlgorithms.calgSHA, CryptoAlgorithms.calg3DES) ' use defaults Line 70:         Dim Blob As ICryptoBlob = key.EncryptText(UserID)

Source File: Line: 68

Stack Trace:

[COMException (0x800a0001): Object already exists. ]    ASPENCRYPTLib.CryptoManagerClass.OpenContext(String Container, Int32 bMachineKey, Object CreateNew) +0    security.Encrypt(String UserID) in C:\Shared\Projects\Schriaz_TMF\SourceControl\Source\Admin.2005\App_Code\security.vb:68    ucontrols.forms.login.LoginAdmin(Boolean blnPersist) in C:\Shared\Projects\Schriaz_TMF\SourceControl\Source\Admin.2005\controls\forms\login.ascx.vb:278    ucontrols.forms.login.CheckLogin() in C:\Shared\Projects\Schriaz_TMF\SourceControl\Source\Admin.2005\controls\forms\login.ascx.vb:223    ucontrols.forms.login.btLoginCen_Click(Object sender, ImageClickEventArgs e) in C:\Shared\Projects\Schriaz_TMF\SourceControl\Source\Admin.2005\controls\forms\login.ascx.vb:584    System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +86    System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +115    System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746 


Version Information: Microsoft .NET Framework Version:2.0.50727.1434; ASP.NET Version:2.0.50727.1434

Saturday, May 3, 2008

Could not load file or assembly '' or one of its dependencies. Access is denied.

Standard Solution
This is one of the most irritating build errors a developer might see, especially while setting up an existing .NET application on a fresh machine. I have found one solution that works always. Go to:

"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files"
( Modify the framework version, root directory etc according to your environment. )

Now, right-click and open up the Security tabs for this folder. Grant "Full control" to the 'users' group. (Modify will also work, thought I didn't try it out) However, it this is a security problem for your environment to grant full control to all users in Users group, another Solution could be to put the concerned assemblies lo GAC which I avoided as it was not logical to put the assemblies into GAC in my scenario. Hope this helps.

My Experience
In reality I did the above and it didn't fix the problem so I had to right click each dll that had the problem in the projects bin folder (not temporart asp.net folders) and add group everyone and give it full permissions.