Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Getting error System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

Someone guide me to resolve the Error.

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ServiceModel.FaultException: The provided asset id [000000002] is invalid

Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at References.AssetsService.AssetsPort.saveAsset(saveAssetRequest1 request)
at References.AssetsService.AssetsPortClient.References.AssetsService.AssetsPort.saveAsset(saveAssetRequest1 request)
at References.AssetsService.AssetsPortClient.saveAsset(saveAssetRequest saveAssetRequest)
at Dynamics.Ax.Application.InterfaceBatch.assetservice() in InterfaceBatch.AssetService.xpp:line 366

*This post is locked for comments

  • Martin Dráb Profile Picture
    Martin Dráb 230,371 Most Valuable Professional on at
    RE: Getting error System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation

    Yes, I know it's taken from LogisticsLocation, but that's not what either I or the error message were talking about. The message says that you're trying to use it as an asset ID. It seems that you the value in a wrong and you're not aware of it, but I can't comment on the code of your service as I've never seen it (you gave us just a snippet of the client code).

    If you can't find the bug just by looking at your code, use the debugger to find the problem at runtime. Note that AX code called from services is executed in CIL, therefore you would need the Visual Studio debugger attached to the AOS process. As usual, you can find details in documentation (Debugging in Microsoft Dynamics AX 2012).

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Getting error System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation

    yes this "000000002" id is present in "logisticsLocation".

    It is customized services.

  • Martin Dráb Profile Picture
    Martin Dráb 230,371 Most Valuable Professional on at
    RE: Getting error System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation

    Using location  ID as asset ID looks suspicious. Are you sure that asset ID 000000002 exists and that the whole logic makes sense?

    Also, what service are you calling?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Getting error System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation

    Hi Martin,

    I am Accessing the dll in AX.

    Exception is throwed in "assetclient.saveAsset(request);"

    I am having code like this.

    request.set_Id(logisticsLocation.LocationId ? logisticsLocation.LocationId : logisticsLocation.Inv_LocationId); //Asset id "000000002"is taken from logisticsLocation table.

    request.set_purchaseOrder(salesTable.PurchorderFormNum);

    utcDateTimeRoute = WMSPickingRoute::find(wmsOrderTransTmp.routeId).ActivationDateTime;

    netDttm = utcDateTimeRoute; // Marshals.

    request.set_purchaseDate(netDttm);   request.set_assetClassName(InventTable::getassetclassName(wmsOrderTransTmp.itemId));       request.set_serialNumber(InventDim::find(wmsOrderTransTmp.inventDimId).inventSerialId);

    request.set_createdDate(Global::utcDateTime2SystemDateTime(time)); request.set_createdDateSpecified(true);

    request.set_customFields(customField);

    assetclient.saveAsset(request); //above exception is throws in this line

    assetclient.Close();

    assetclient.Dispose();

    can guide me to resolve the error.

  • Martin Dráb Profile Picture
    Martin Dráb 230,371 Most Valuable Professional on at
    RE: Getting error System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation

    Unfortunately you forgot to provide any information about what you're doing. Anyway, the error says that "The provided asset id [000000002] is invalid", so that's what you should focus on.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,642 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,371 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans