locked
System.InvalidCastException: Specified cast is not valid RRS feed

  • Question

  • Hi,

    I am using CRM4.0,When I try to import an exiting organization on a other server and domain, I am able to walkthrough the import organization wizard. However when the import starts is almost stops immediately with the following error:

    Import Organization (Name=xxxxx, Id=xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx) failed with Exception:
    System.InvalidCastException: Specified cast is not valid.

    Has anyone an idea how to solve this??

    thanks in advance !!


    Tuesday, July 19, 2011 9:59 AM

Answers

  • Thanks.  Feel free to come back and mark my posts as helpful.   It's just too hard for someone without remote access to diagnose the problem when it's dealing with a manual database change.  It's somthing that Microsoft can do.  You can literally give them access to  your environment and watch them troubleshoot it.  There is probably little that someone in the forum could help you without A LOT of going back and forth.


    Jamie Miley
    Check out my about.me profile!
    http://mileyja.blogspot.com
    Linked-In Profile
    Follow Me on Twitter!
    • Marked as answer by SEAN ANN Friday, August 5, 2011 12:59 AM
    Monday, July 25, 2011 1:57 PM
    Moderator

All replies

  • I would do a platform trace to try to figure out what is actually being cast.

    Where there any manual db changes to 4.0 db prior to the import.
    Jamie Miley
    Check out my about.me profile!
    http://mileyja.blogspot.com
    Linked-In Profile
    Follow Me on Twitter!
    Wednesday, July 20, 2011 3:28 PM
    Moderator
  • thanks for reply!

    I have a trace log,it shows below like this:

    at SoapHeaderAuthenticationProviderBase.Authenticate(HttpApplication application)
    at AuthenticationStep.Authenticate(HttpApplication application)
    at AuthenticationPipeline.Authenticate(HttpApplication application)
    at AuthenticationEngine.Execute(Object sender, EventArgs e)
    at SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    at HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
    at ApplicationStepManager.ResumeSteps(Exception error)
    at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
    at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
    at HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr)
    at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
    >AUTH: MultipleOrganizationSoapHeaderAuthenticationProvider reject request http://localhost:7002/MSCRMServices/2007/CrmService.asmx because Microsoft.Crm.CrmConfigObjectNotFoundException: Organization With Id = b91eba4a-eca5-e011-995c-0026182ff465 Does Not Exist
    在 Microsoft.Crm.ServerLocatorService.GetConnectionString(Guid organizationId)
    在 Microsoft.Crm.CrmSqlConnectionManagerFactory.CreateConnectionManager(Guid organizationId)
    在 Microsoft.Crm.CrmDbConnection.get_ConnectionManager()
    在 Microsoft.Crm.CrmDbConnection.GetCreateConnection()
    在 Microsoft.Crm.CrmDbConnection.Open()
    在 Microsoft.Crm.SqlExecutionContext.OnBeginRequest(Boolean startTransaction, IsolationLevel isoLevel)
    在 Microsoft.Crm.BusinessEntities.ExecutionContext.OnBeginRequest(Guid userId, Boolean startTransaction, IsolationLevel isolationLevel, String methodName, ServiceMethodType methodType, OperationContext operationContext, String crmMethodName, CallerOriginToken originToken)
    在 Microsoft.Crm.BusinessEntities.ExecutionContext.OnBeginRequest(Boolean startTransaction)
    在 Microsoft.Crm.Caching.ObjectModelCacheLoader`2.LoadCacheData(TKey key, IOrganizationContext context)
    在 Microsoft.Crm.Caching.BasicCrmCache`2.CreateEntry(TKey key, IOrganizationContext context)
    在 Microsoft.Crm.Caching.BasicCrmCache`2.LookupEntry(TKey key, IOrganizationContext context)
    在 Microsoft.Crm.BusinessEntities.SecurityLibrary.CheckPrivilegeGroupForOrganization(WindowsIdentity identity, IOrganizationContext context)
    在 Microsoft.Crm.BusinessEntities.SecurityLibrary.GetPrivilegedUserCallerAndBusinessGuidsFromThread(WindowsIdentity identity, IOrganizationContext context)
    在 Microsoft.Crm.BusinessEntities.SecurityLibrary.GetCallerAndBusinessGuidsFromThread(WindowsIdentity identity, Guid organizationId)
    在 Microsoft.Crm.Authentication.CrmWindowsIdentity.DoRecognizeUser(String userToken, Guid organizationId)
    在 Microsoft.Crm.Authentication.BaseCrmIdentity.RecognizeCrmUser(Guid organizationId)
    在 Microsoft.Crm.Authentication.CrmWindowsIdentity.RecognizeCrmUser(Guid organizationId, Guid callerId)
    在 Microsoft.Crm.WebServices.AuthenticationProvider.Authenticate(CrmAuthenticationToken token)
    在 Microsoft.Crm.WebServices.SoapHeaderAuthenticationProviderBase.Authenticate(HttpApplication application).

     

    at CrmDBObjectNotFoundException..ctor(String tableName, String columnName, Object id)
    at ServerLocatorService.GetConnectionString(Guid organizationId)
    at CrmSqlConnectionManagerFactory.CreateConnectionManager(Guid organizationId)
    at CrmDbConnection.get_ConnectionManager()
    at CrmDbConnection.GetCreateConnection()
    at CrmDbConnection.Open()
    at SqlExecutionContext.OnBeginRequest(Boolean startTransaction, IsolationLevel isoLevel)
    at ExecutionContext.OnBeginRequest(Guid userId, Boolean startTransaction, IsolationLevel isolationLevel, String methodName, ServiceMethodType methodType, OperationContext operationContext, String crmMethodName, CallerOriginToken originToken)
    at ExecutionContext.OnBeginRequest(Boolean startTransaction)
    at ObjectModelCacheLoader`2.LoadCacheData(TKey key, IOrganizationContext context)
    at BasicCrmCache`2.CreateEntry(TKey key, IOrganizationContext context)
    at BasicCrmCache`2.LookupEntry(TKey key, IOrganizationContext context)
    at SecurityLibrary.CheckPrivilegeGroupForOrganization(WindowsIdentity identity, IOrganizationContext context)
    at SecurityLibrary.GetPrivilegedUserCallerAndBusinessGuidsFromThread(WindowsIdentity identity, IOrganizationContext context)
    at SecurityLibrary.GetCallerAndBusinessGuidsFromThread(WindowsIdentity identity, Guid organizationId)
    at CrmWindowsIdentity.DoRecognizeUser(String userToken, Guid organizationId)
    at BaseCrmIdentity.RecognizeCrmUser(Guid organizationId)
    at CrmWindowsIdentity.RecognizeCrmUser(Guid organizationId, Guid callerId)
    at AuthenticationProvider.Authenticate(CrmAuthenticationToken token)
    at SoapHeaderAuthenticationProviderBase.Authenticate(HttpApplication application)
    at AuthenticationStep.Authenticate(HttpApplication application)
    at AuthenticationPipeline.Authenticate(HttpApplication application)
    at AuthenticationEngine.Execute(Object sender, EventArgs e)
    at SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    at HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
    at ApplicationStepManager.ResumeSteps(Exception error)
    at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
    at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
    at HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr)
    at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
    >Crm Exception: Message: Organization With Id = b91eba4a-eca5-e011-995c-0026182ff465 Does Not Exist, ErrorCode: -2147220969

    and it also show the error

    at CrmException..ctor(String message, Exception innerException, Int32 errorCode)
    at ImportOrganizationInstaller.Import(Guid organizationId, String organizationUniqueName, String organizationFriendlyName, String sqlServerName, String databaseName, Uri reportServerUrl, String privilegedUserGroupName, String sqlAccessGroupName, String userGroupName, String reportingGroupName, String privilegedReportingGroupName, ICollection`1 users, MultipleTenancy multipleTenancy)
    at ImportOrganizationInstaller.Import(IImportOrganizationInfo organizationInfo)
    at ImportOrganizationInstaller.Execute(Object obj)
    at ProgressController.ExecuteHandler()
    at StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
    at StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
    at AgileAsyncWorkerItem.ThreadPoolCallBack(Object o)
    at ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    at _ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)
    at _ThreadPoolWaitCallback.PerformWaitCallback(Object state)
    >Crm Exception: Message: import organization(name=org,ID=792b48b1-eea5-e011-995c-0026182ff465)fail,occur exception:
    System.InvalidCastException: specified cast invalid。
    在 Microsoft.Crm.Tools.Admin.ImportOrganizationInstaller.Import(Guid organizationId, String organizationUniqueName, String organizationFriendlyName, String sqlServerName, String databaseName, Uri reportServerUrl, String privilegedUserGroupName, String sqlAccessGroupName, String userGroupName, String reportingGroupName, String privilegedReportingGroupName, ICollection`1 users, MultipleTenancy multipleTenancy), ErrorCode: -2147176447, InnerException: System.InvalidCastException: specified cast invalid。
    在 Microsoft.Crm.Tools.Admin.ImportOrganizationInstaller.Import(Guid organizationId, String organizationUniqueName, String organizationFriendlyName, String sqlServerName, String databaseName, Uri reportServerUrl, String privilegedUserGroupName, String sqlAccessGroupName, String userGroupName, String reportingGroupName, String privilegedReportingGroupName, ICollection`1 users, MultipleTenancy multipleTenancy)

     

    Thursday, July 21, 2011 8:28 AM
  • The other question I was wondering about is whether or not you have made any manual changes to the CRM databases?


    Jamie Miley
    Check out my about.me profile!
    http://mileyja.blogspot.com
    Linked-In Profile
    Follow Me on Twitter!
    Thursday, July 21, 2011 2:47 PM
    Moderator
  • Hi Jamie,

    Actually,I haven't changed the Crm Database,but I'm not sure it haven't changed by other people.

    I tried to recover the old database(org_mscrm),but it still didn't work.

    thanks.

     

    Friday, July 22, 2011 2:31 AM
  • This may or not be related to a database change then.  I would recommend contacting Microsoft and they should be able to help you determine if there are changes or not and they can help you fix the problem.

    I don't know how to fix this problem and no on else has replied so I think that is your next step.  The support number is:

    • 877-276-2464

     


    Jamie Miley
    Check out my about.me profile!
    http://mileyja.blogspot.com
    Linked-In Profile
    Follow Me on Twitter!
    Friday, July 22, 2011 1:26 PM
    Moderator
  • No matter what,thank you Jamie!
    Monday, July 25, 2011 12:31 AM
  • Thanks.  Feel free to come back and mark my posts as helpful.   It's just too hard for someone without remote access to diagnose the problem when it's dealing with a manual database change.  It's somthing that Microsoft can do.  You can literally give them access to  your environment and watch them troubleshoot it.  There is probably little that someone in the forum could help you without A LOT of going back and forth.


    Jamie Miley
    Check out my about.me profile!
    http://mileyja.blogspot.com
    Linked-In Profile
    Follow Me on Twitter!
    • Marked as answer by SEAN ANN Friday, August 5, 2011 12:59 AM
    Monday, July 25, 2011 1:57 PM
    Moderator
  • Has this problem been resolved?  I'm receiving the same error message for an org import from into a 4.0 deployment from another 4.0 deployment in another domain.  Unfortunately, the error message provides no guidance on how to resolve and proceed.

    Thanks,

    Jeff

    Monday, November 12, 2012 12:11 PM
  • Jeff, 

    You are going to want to ask this question in another thread I think.  That way other people will see it and you will have a better chance of getting it answered.  The invalid cast exception is pretty generic and you will probably also want to provide your code for ease in helping along with any other stack trace info provided in the error.

    Thanks!


    Jamie Miley
    Check out my about.me profile!
    http://mileyja.blogspot.com
    Linked-In Profile
    Follow Me on Twitter!

    Monday, November 12, 2012 9:25 PM
    Moderator