web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
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

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

I have the same question (0)
  • Martin Dráb Profile Picture
    236,949 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.

  • Community Member Profile Picture
    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
    236,949 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
    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
    236,949 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).

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 3

#3
Community Member Profile Picture

Community Member 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans